internal/mcp: add batching support
Update the jsonrpc2 MCP framer to support both incoming and outgoing batches. In order to achieve this, we must correlate the framed Reader and Writer, which is not explicitly supported by the jsonrpc2 API, but does work. A note is left to revisit the Framer interface. Change-Id: If060cb5822da067833db20d58f5f112a0528da91 Reviewed-on: https://go-review.googlesource.com/c/tools/+/667295 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
34cc770852
commit
1204b93a85
1 changed files with 324 additions and 12 deletions
|
|
@ -39,6 +39,15 @@ type Writer interface {
|
|||
// Framer wraps low level byte readers and writers into jsonrpc2 message
|
||||
// readers and writers.
|
||||
// It is responsible for the framing and encoding of messages into wire form.
|
||||
//
|
||||
// TODO(rfindley): rethink the framer interface, as with JSONRPC2 batching
|
||||
// there is a need for Reader and Writer to be correlated, and while the
|
||||
// implementation of framing here allows that, it is not made explicit by the
|
||||
// interface.
|
||||
//
|
||||
// Perhaps a better interface would be
|
||||
//
|
||||
// Frame(io.ReadWriteCloser) (Reader, Writer).
|
||||
type Framer interface {
|
||||
// Reader wraps a byte reader into a message reader.
|
||||
Reader(io.Reader) Reader
|
||||
|
|
|
|||
Loading…
Reference in a new issue