This is an archive of the discontinued Mercurial Phabricator instance.

httppeer: implement command executor for version 2 peer
ClosedPublic

Authored by indygreg on Apr 12 2018, 3:59 PM.

Details

Summary

Now that we have a new API for issuing commands which is compatible
with wire protocol version 2, we can start using it with wire protocol
version 2.

This commit replaces our hacky implementation of _call() with something
a bit more robust based on the new command executor interface.

We now have proper support for issuing multiple commands per HTTP
request. Each HTTP request maintains its own client reactor.

The implementation is similar to the one in the legacy wire protocol.
We use a ThreadPoolExecutor for spinning up a thread to read the HTTP
response in the background. This allows responses to resolve in any
order. While not implemented on the server yet, a client could use
concurrent.futures.as_completed() with a collection of futures and
handle responses as they arrive from the server.

The return value from issued commands is still a simple list of raw
or decoded CBOR data. This is still super hacky. We will want a rich
data type for representing command responses. But at least this
commit gets us one step closer to a proper peer implementation.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Apr 12 2018, 3:59 PM
indygreg updated this revision to Diff 8102.Apr 12 2018, 8:32 PM
indygreg planned changes to this revision.Apr 13 2018, 3:22 PM

This needs some revisions to adapt to the tweaked command executor interface semantics.

indygreg updated this revision to Diff 8153.Apr 13 2018, 5:36 PM
durin42 accepted this revision.Apr 13 2018, 6:06 PM
This revision is now accepted and ready to land.Apr 13 2018, 6:06 PM
This revision was automatically updated to reflect the committed changes.