D2947: wireproto: explicit API to create outgoing streams
This revision was automatically updated to reflect the committed changes. Closed by commit rHG5fadc63ac99f: wireproto: explicit API to create outgoing streams (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2947?vs=7436=7550 REVISION DETAIL https://phab.mercurial-scm.org/D2947 AFFECTED FILES mercurial/wireprotoframing.py mercurial/wireprotoserver.py tests/test-http-api-httpv2.t tests/test-wireproto-serverreactor.py CHANGE DETAILS diff --git a/tests/test-wireproto-serverreactor.py b/tests/test-wireproto-serverreactor.py --- a/tests/test-wireproto-serverreactor.py +++ b/tests/test-wireproto-serverreactor.py @@ -375,7 +375,7 @@ """Multiple fully serviced commands with same request ID is allowed.""" reactor = makereactor() results = [] -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() results.append(self._sendsingleframe( reactor, ffs(b'1 1 stream-begin command-name eos command'))) result = reactor.onbytesresponseready(outstream, 1, b'response1') @@ -530,7 +530,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -546,7 +546,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, first + second) self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -559,7 +559,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onapplicationerror(outstream, 1, b'some message') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -575,7 +575,7 @@ self.assertEqual(len(results), 1) self.assertaction(results[0], 'runcommand') -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'noop') result = reactor.oninputeof() @@ -590,7 +590,7 @@ list(sendcommandframes(reactor, instream, 1, b'command1', {})) list(sendcommandframes(reactor, instream, 3, b'command2', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response1') self.assertaction(result, 'noop') result = reactor.onbytesresponseready(outstream, 3, b'response2') @@ -610,7 +610,7 @@ list(sendcommandframes(reactor, instream, 5, b'command3', {})) # Register results for commands out of order. -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 3, b'response3') reactor.onbytesresponseready(outstream, 1, b'response1') reactor.onbytesresponseready(outstream, 5, b'response5') @@ -640,7 +640,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 1, b'response') # We've registered the response but haven't sent it. From the @@ -672,7 +672,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() res = reactor.onbytesresponseready(outstream, 1, b'response') list(res[1]['framegen']) diff --git a/tests/test-http-api-httpv2.t b/tests/test-http-api-httpv2.t --- a/tests/test-http-api-httpv2.t +++ b/tests/test-http-api-httpv2.t @@ -472,7 +472,7 @@ s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response s> \r\n s> 25\r\n - s> \x1d\x00\x00\x03\x00\x02\x01Bcustomreadonly bytes response + s> \x1d\x00\x00\x03\x00\x02\x00Bcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -511,7 +511,7 @@ s> \x00\x00\x00\x03\x00\x02\x01B s> \r\n s> 26\r\n - s> \x1e\x00\x00\x01\x00\x02\x01Bbookmarks\n + s> \x1e\x00\x00\x01\x00\x02\x00Bbookmarks\n
D2947: wireproto: explicit API to create outgoing streams
indygreg updated this revision to Diff 7436. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2947?vs=7326=7436 REVISION DETAIL https://phab.mercurial-scm.org/D2947 AFFECTED FILES mercurial/wireprotoframing.py mercurial/wireprotoserver.py tests/test-http-api-httpv2.t tests/test-wireproto-serverreactor.py CHANGE DETAILS diff --git a/tests/test-wireproto-serverreactor.py b/tests/test-wireproto-serverreactor.py --- a/tests/test-wireproto-serverreactor.py +++ b/tests/test-wireproto-serverreactor.py @@ -375,7 +375,7 @@ """Multiple fully serviced commands with same request ID is allowed.""" reactor = makereactor() results = [] -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() results.append(self._sendsingleframe( reactor, ffs(b'1 1 stream-begin command-name eos command'))) result = reactor.onbytesresponseready(outstream, 1, b'response1') @@ -530,7 +530,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -546,7 +546,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, first + second) self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -559,7 +559,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onapplicationerror(outstream, 1, b'some message') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -575,7 +575,7 @@ self.assertEqual(len(results), 1) self.assertaction(results[0], 'runcommand') -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'noop') result = reactor.oninputeof() @@ -590,7 +590,7 @@ list(sendcommandframes(reactor, instream, 1, b'command1', {})) list(sendcommandframes(reactor, instream, 3, b'command2', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response1') self.assertaction(result, 'noop') result = reactor.onbytesresponseready(outstream, 3, b'response2') @@ -610,7 +610,7 @@ list(sendcommandframes(reactor, instream, 5, b'command3', {})) # Register results for commands out of order. -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 3, b'response3') reactor.onbytesresponseready(outstream, 1, b'response1') reactor.onbytesresponseready(outstream, 5, b'response5') @@ -640,7 +640,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 1, b'response') # We've registered the response but haven't sent it. From the @@ -672,7 +672,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() res = reactor.onbytesresponseready(outstream, 1, b'response') list(res[1]['framegen']) diff --git a/tests/test-http-api-httpv2.t b/tests/test-http-api-httpv2.t --- a/tests/test-http-api-httpv2.t +++ b/tests/test-http-api-httpv2.t @@ -472,7 +472,7 @@ s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response s> \r\n s> 25\r\n - s> \x1d\x00\x00\x03\x00\x02\x01Bcustomreadonly bytes response + s> \x1d\x00\x00\x03\x00\x02\x00Bcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -511,7 +511,7 @@ s> \x00\x00\x00\x03\x00\x02\x01B s> \r\n s> 26\r\n - s> \x1e\x00\x00\x01\x00\x02\x01Bbookmarks\n + s> \x1e\x00\x00\x01\x00\x02\x00Bbookmarks\n s> namespaces\n s> phases s> \r\n diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py ---
D2947: wireproto: explicit API to create outgoing streams
indygreg updated this revision to Diff 7326. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2947?vs=7309=7326 REVISION DETAIL https://phab.mercurial-scm.org/D2947 AFFECTED FILES mercurial/wireprotoframing.py mercurial/wireprotoserver.py tests/test-http-api-httpv2.t tests/test-wireproto-serverreactor.py CHANGE DETAILS diff --git a/tests/test-wireproto-serverreactor.py b/tests/test-wireproto-serverreactor.py --- a/tests/test-wireproto-serverreactor.py +++ b/tests/test-wireproto-serverreactor.py @@ -375,7 +375,7 @@ """Multiple fully serviced commands with same request ID is allowed.""" reactor = makereactor() results = [] -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() results.append(self._sendsingleframe( reactor, ffs(b'1 1 stream-begin command-name eos command'))) result = reactor.onbytesresponseready(outstream, 1, b'response1') @@ -530,7 +530,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -546,7 +546,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, first + second) self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -559,7 +559,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onapplicationerror(outstream, 1, b'some message') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -575,7 +575,7 @@ self.assertEqual(len(results), 1) self.assertaction(results[0], 'runcommand') -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'noop') result = reactor.oninputeof() @@ -590,7 +590,7 @@ list(sendcommandframes(reactor, instream, 1, b'command1', {})) list(sendcommandframes(reactor, instream, 3, b'command2', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response1') self.assertaction(result, 'noop') result = reactor.onbytesresponseready(outstream, 3, b'response2') @@ -610,7 +610,7 @@ list(sendcommandframes(reactor, instream, 5, b'command3', {})) # Register results for commands out of order. -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 3, b'response3') reactor.onbytesresponseready(outstream, 1, b'response1') reactor.onbytesresponseready(outstream, 5, b'response5') @@ -640,7 +640,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 1, b'response') # We've registered the response but haven't sent it. From the @@ -672,7 +672,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() res = reactor.onbytesresponseready(outstream, 1, b'response') list(res[1]['framegen']) diff --git a/tests/test-http-api-httpv2.t b/tests/test-http-api-httpv2.t --- a/tests/test-http-api-httpv2.t +++ b/tests/test-http-api-httpv2.t @@ -472,7 +472,7 @@ s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response s> \r\n s> 25\r\n - s> \x1d\x00\x00\x03\x00\x02\x01Bcustomreadonly bytes response + s> \x1d\x00\x00\x03\x00\x02\x00Bcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -511,7 +511,7 @@ s> \x00\x00\x00\x03\x00\x02\x01B s> \r\n s> 26\r\n - s> \x1e\x00\x00\x01\x00\x02\x01Bbookmarks\n + s> \x1e\x00\x00\x01\x00\x02\x00Bbookmarks\n s> namespaces\n s> phases s> \r\n diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py ---
D2947: wireproto: explicit API to create outgoing streams
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY It is better to create outgoing streams through the reactor so the reactor knows about what streams are active and can track them accordingly. Test output changes slightly because frames from subsequent responses no longer have the "stream begin" stream flag set because the stream is now used across all responses. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2947 AFFECTED FILES mercurial/wireprotoframing.py mercurial/wireprotoserver.py tests/test-http-api-httpv2.t tests/test-wireproto-serverreactor.py CHANGE DETAILS diff --git a/tests/test-wireproto-serverreactor.py b/tests/test-wireproto-serverreactor.py --- a/tests/test-wireproto-serverreactor.py +++ b/tests/test-wireproto-serverreactor.py @@ -519,7 +519,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -535,7 +535,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, first + second) self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -548,7 +548,7 @@ instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'mycommand', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onapplicationerror(outstream, 1, b'some message') self.assertaction(result, 'sendframes') self.assertframesequal(result[1]['framegen'], [ @@ -564,7 +564,7 @@ self.assertEqual(len(results), 1) self.assertaction(results[0], 'runcommand') -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response') self.assertaction(result, 'noop') result = reactor.oninputeof() @@ -579,7 +579,7 @@ list(sendcommandframes(reactor, instream, 1, b'command1', {})) list(sendcommandframes(reactor, instream, 3, b'command2', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() result = reactor.onbytesresponseready(outstream, 1, b'response1') self.assertaction(result, 'noop') result = reactor.onbytesresponseready(outstream, 3, b'response2') @@ -599,7 +599,7 @@ list(sendcommandframes(reactor, instream, 5, b'command3', {})) # Register results for commands out of order. -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 3, b'response3') reactor.onbytesresponseready(outstream, 1, b'response1') reactor.onbytesresponseready(outstream, 5, b'response5') @@ -629,7 +629,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() reactor.onbytesresponseready(outstream, 1, b'response') # We've registered the response but haven't sent it. From the @@ -661,7 +661,7 @@ reactor = makereactor() instream = framing.stream(1) list(sendcommandframes(reactor, instream, 1, b'command1', {})) -outstream = framing.stream(2) +outstream = reactor.makeoutputstream() res = reactor.onbytesresponseready(outstream, 1, b'response') list(res[1]['framegen']) diff --git a/tests/test-http-api-httpv2.t b/tests/test-http-api-httpv2.t --- a/tests/test-http-api-httpv2.t +++ b/tests/test-http-api-httpv2.t @@ -472,7 +472,7 @@ s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response s> \r\n s> 25\r\n - s> \x1d\x00\x00\x03\x00\x02\x01Bcustomreadonly bytes response + s> \x1d\x00\x00\x03\x00\x02\x00Bcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -511,7 +511,7 @@ s> \x00\x00\x00\x03\x00\x02\x01B s> \r\n s> 26\r\n - s> \x1e\x00\x00\x01\x00\x02\x01Bbookmarks\n + s> \x1e\x00\x00\x01\x00\x02\x00Bbookmarks\n s> namespaces\n s> phases s> \r\n diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py --- a/mercurial/wireprotoserver.py +++ b/mercurial/wireprotoserver.py @@ -432,6 +432,8 @@ reactor =