Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientDecorator ¶
ClientDecorator is a function that enable to decorate a JSON-RPC client with additional functionality
func WithIncrementalID ¶
func WithIncrementalID() ClientDecorator
WithIncrementalID automatically increments JSON-RPC request ID
func WithLog ¶
func WithLog(namespaces ...string) ClientDecorator
func WithTags ¶
func WithTags(component string, namespaces ...string) ClientDecorator
It also attaches the provided component name to the default component tag.
func WithTimeout ¶
func WithTimeout(d time.Duration) ClientDecorator
WithTimeout automatically sets a timeout for JSON-RPC calls
func WithVersion ¶
func WithVersion(v string) ClientDecorator
WithVersion automatically set JSON-RPC request version
type ClientFunc ¶
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 an error in a JSON-RPC response body
type RequestMsg ¶
type RequestMsg struct { Version string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` ID interface{} `json:"id,omitempty"` }
RequestMsg is a struct allowing to encode/decode a JSON-RPC request body
type ResponseMsg ¶
type ResponseMsg struct { Version string `json:"jsonrpc"` Result json.RawMessage `json:"result,omitempty"` Error json.RawMessage `json:"error,omitempty"` ID interface{} `json:"id,omitempty"` }
ResponseMsg is a struct allowing to encode/decode a JSON-RPC response body
func DecodeResponseMsg ¶
func DecodeResponseMsg(r io.Reader) (*ResponseMsg, error)
DecodeResponseMsg decodes a JSON-RPC response message from an io.Reader
func (*ResponseMsg) Unmarshal ¶
func (msg *ResponseMsg) Unmarshal(res interface{}) error
Unmarshal unmarshals a JSON-RPC response result into a given interface If the response contains an error, it will be unmarshaled into an ErrorMsg and returned