mcp: implement a concurrency model for calls
Implement the concurrency model described in #26: notifications are synchronous, but calls are asynchronous (except for 'initialize'). To achieve this, implement jsonrpc2.Async(ctx) to signal asynchronous handling. This is simpler to use than returning ErrAsyncResponse and calling Respond, and since this is an internal detail we don't need to worry too much about whether it's idiomatic. Add tests that verify both features, for both client and server. Also: - replace req.ID.IsValid with req.IsCall - remove the methodHandler type as we can just use MethodHandler Fixes #26
This commit is contained in:
parent
112ca4e3b1
commit
3db848abec
1 changed files with 208 additions and 86 deletions
|
|
@ -689,7 +689,7 @@ func TestStreamableServerTransport(t *testing.T) {
|
|||
defer wg.Done()
|
||||
|
||||
for m := range out {
|
||||
if req, ok := m.(*jsonrpc.Request); ok && req.ID.IsValid() {
|
||||
if req, ok := m.(*jsonrpc.Request); ok && req.IsCall() {
|
||||
// Encountered a server->client request. We should have a
|
||||
// response queued. Otherwise, we may deadlock.
|
||||
mu.Lock()
|
||||
|
|
|
|||
Loading…
Reference in a new issue