Documentation ¶
Index ¶
- type CallHandler
- type Connection
- func (c *Connection) Call(ctx context.Context, method string, params ...any) (json.RawMessage, error)
- func (c *Connection) Close() error
- func (c *Connection) DropPending(id string)
- func (c *Connection) Error() error
- func (c *Connection) Handle(method string, handler NotificationHandler) error
- func (c *Connection) HandleCall(method string, handler CallHandler) error
- func (c *Connection) Notify(ctx context.Context, method string, params ...any) error
- func (c *Connection) Send(ctx context.Context, method string, params ...any) (<-chan *Response, string, error)
- type NotificationHandler
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallHandler ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
A Connection is a JSON-RPC connection.
func NewConnection ¶
func NewConnection(network, addr string, _log *zap.SugaredLogger) (*Connection, error)
NewConnection creates a new Connection
func (*Connection) Call ¶
func (c *Connection) Call(ctx context.Context, method string, params ...any) (json.RawMessage, error)
Call sends a single JSON-RPC request synchronously.
func (*Connection) DropPending ¶
func (c *Connection) DropPending(id string)
func (*Connection) Error ¶
func (c *Connection) Error() error
func (*Connection) Handle ¶
func (c *Connection) Handle(method string, handler NotificationHandler) error
Handle sets notification handler for incoming JSON-RPC notification.
func (*Connection) HandleCall ¶
func (c *Connection) HandleCall(method string, handler CallHandler) error
HandleCall sets call handler for incoming JSON-RPC call.
type NotificationHandler ¶
type NotificationHandler func(params []byte)
type Response ¶
type Response struct { ID *string `json:"id"` // ID Non-null for response; null for request notification. // used for requests Res json.RawMessage `json:"result,omitempty"` // Res here is raw results from JSON-RPC server. Err interface{} `json:"error,omitempty"` // used for notifications Method string `json:"method,omitempty"` // Method is method name notification. Params json.RawMessage `json:"params,omitempty"` // Params is notification object }
Response can be JSON-RPC response, or JSON-RPC request notification
func (*Response) IsNotification ¶
IsNotification returns true if response is a notification
Click to show internal directories.
Click to hide internal directories.