Versions in this module Expand all Collapse all v0 v0.5.1 Jan 24, 2023 Changes in this version + const ErrIdleTimeout + var ErrInternal = NewError(-32603, "JSON RPC internal error") + var ErrInvalidParams = NewError(-32602, "JSON RPC invalid params") + var ErrInvalidRequest = NewError(-32600, "JSON RPC invalid request") + var ErrMethodNotFound = NewError(-32601, "JSON RPC method not found") + var ErrParse = NewError(-32700, "JSON RPC parse error") + var ErrServerOverloaded = NewError(-32000, "JSON RPC overloaded") + var ErrUnknown = NewError(-32001, "JSON RPC unknown error") + func ListenAndServe(ctx context.Context, network, addr string, server StreamServer, ...) error + func MethodNotFound(ctx context.Context, reply Replier, req Request) error + func NewError(code int64, message string) error + func Serve(ctx context.Context, ln net.Listener, server StreamServer, ...) error + type Call struct + func NewCall(id ID, method string, params interface{}) (*Call, error) + func (c *Call) MarshalJSON() ([]byte, error) + func (c *Call) UnmarshalJSON(data []byte) error + func (msg *Call) ID() ID + func (msg *Call) Method() string + func (msg *Call) Params() json.RawMessage + type Conn interface + Call func(ctx context.Context, method string, params, result interface{}) (ID, error) + Close func() error + Done func() <-chan struct{} + Err func() error + Go func(ctx context.Context, handler Handler) + Notify func(ctx context.Context, method string, params interface{}) error + func NewConn(s Stream) Conn + type Framer func(conn net.Conn) Stream + type Handler func(ctx context.Context, reply Replier, req Request) error + func AsyncHandler(handler Handler) Handler + func CancelHandler(handler Handler) (Handler, func(id ID)) + func MustReplyHandler(handler Handler) Handler + type ID struct + func NewIntID(v int64) ID + func NewStringID(v string) ID + func (id *ID) MarshalJSON() ([]byte, error) + func (id *ID) UnmarshalJSON(data []byte) error + func (id ID) Format(f fmt.State, r rune) + type Message interface + func DecodeMessage(data []byte) (Message, error) + type Notification struct + func NewNotification(method string, params interface{}) (*Notification, error) + func (msg *Notification) Method() string + func (msg *Notification) Params() json.RawMessage + func (n *Notification) MarshalJSON() ([]byte, error) + func (n *Notification) UnmarshalJSON(data []byte) error + type Replier func(ctx context.Context, result interface{}, err error) error + type Request interface + Method func() string + Params func() json.RawMessage + type Response struct + func NewResponse(id ID, result interface{}, err error) (*Response, error) + func (msg *Response) Err() error + func (msg *Response) ID() ID + func (msg *Response) Result() json.RawMessage + func (r *Response) MarshalJSON() ([]byte, error) + func (r *Response) UnmarshalJSON(data []byte) error + type ServerFunc func(context.Context, Conn) error + func (f ServerFunc) ServeStream(ctx context.Context, c Conn) error + type Stream interface + Close func() error + Read func(context.Context) (Message, int64, error) + Write func(context.Context, Message) (int64, error) + func NewHeaderStream(conn net.Conn) Stream + func NewRawStream(conn net.Conn) Stream + type StreamServer interface + ServeStream func(context.Context, Conn) error + func HandlerServer(h Handler) StreamServer