mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
add JSONRPC2 interface
This commit is contained in:
parent
efb0c1941c
commit
3b45ab3a66
1 changed files with 17 additions and 0 deletions
17
jsonrpc2.go
17
jsonrpc2.go
|
|
@ -17,6 +17,21 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// JSONRPC2 describes an interface for issuing requests that speak the
|
||||
// JSON-RPC 2 protocol. It isn't really necessary for this package
|
||||
// itself, but is useful for external users that use the interface as
|
||||
// an API boundary.
|
||||
type JSONRPC2 interface {
|
||||
// Call issues a standard request (http://www.jsonrpc.org/specification#request_object).
|
||||
Call(ctx context.Context, method string, params, result interface{}, opt ...CallOption) error
|
||||
|
||||
// Notify issues a notification request (http://www.jsonrpc.org/specification#notification).
|
||||
Notify(ctx context.Context, method string, params interface{}, opt ...CallOption) error
|
||||
|
||||
// Close closes the underlying connection, if it exists.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// Request represents a JSON-RPC request or
|
||||
// notification. See
|
||||
// http://www.jsonrpc.org/specification#request_object and
|
||||
|
|
@ -203,6 +218,8 @@ type Conn struct {
|
|||
onSend func(*Request, *Response)
|
||||
}
|
||||
|
||||
var _ JSONRPC2 = (*Conn)(nil)
|
||||
|
||||
// ErrClosed indicates that the JSON-RPC connection is closed (or in
|
||||
// the process of closing).
|
||||
var ErrClosed = errors.New("jsonrpc2: connection is closed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue