jsonrpc

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {

	// res MUST be a pointer so JSON-RPC result can be unmarshalled into res. You
	// can also pass nil, in which case the result is ignored.
	Call(ctx context.Context, req *Request, res interface{}) error
}

type ClientDecorator

type ClientDecorator func(Client) Client

func WithIncrementalID

func WithIncrementalID() ClientDecorator

WithIncrementalID automatically increments JSON-RPC request ID

func WithVersion

func WithVersion(v string) ClientDecorator

WithVersion automatically set JSON-RPC request version

type ClientFunc

type ClientFunc func(ctx context.Context, req *Request, res interface{}) error

func (ClientFunc) Call

func (f ClientFunc) Call(ctx context.Context, req *Request, res interface{}) error

type ErrorMsg

type ErrorMsg struct {
	Code    int              `json:"code"`
	Message string           `json:"message"`
	Data    *json.RawMessage `json:"data,omitempty"`
}

ErrorMsg is a struct allowing to encode/decode a JSON-RPC response body

func (ErrorMsg) Error

func (err ErrorMsg) Error() string

type Request

type Request struct {
	Version string
	Method  string
	ID      interface{}
	Params  interface{}
}

Request allows to manipulate a JSON-RPC request

func (*Request) MarshalJSON

func (msg *Request) MarshalJSON() ([]byte, error)

MarshalJSON

Directories

Path Synopsis
Package jsonrpctestutils is a generated GoMock package.
Package jsonrpctestutils is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL