sourcegraph / jsonrpc2

Package jsonrpc2 provides a client and server implementation of JSON-RPC 2.0 (http://www.jsonrpc.org/specification)
MIT License
195 stars 62 forks source link

Break the Call method into a dispatcher and waiter #41

Closed corneliusweig closed 3 years ago

corneliusweig commented 3 years ago

Before, the Call method dispatched the JSON-RPC request and waited until completion of the request before returning. This made it difficult to release any locks that need to be released upon dispatch.

Now, the Call method is broken into a DispatchCall and Wait pair. DispatchCall returns a proxy to the internal call object as soon as the request is dispatched. When appropriate, the caller can invoke the Wait method on this proxy to block until the result is ready.

The original Call method is not changed, but now implemented by these primitives.