jsonrpc2

package
v1.5.14 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: GPL-3.0 Imports: 12 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 struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(addr string) (*Client, error)

func DiscoverAndDial

func DiscoverAndDial(target, protocol string) (client *Client, err error)

func (*Client) Call

func (c *Client) Call(res interface{}, method string, params ...interface{}) error

func (*Client) CallRequest

func (c *Client) CallRequest(res interface{}, req *Request) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) SendRawRequest

func (c *Client) SendRawRequest(req *Request) (*Message, error)

func (*Client) Subscribe

func (c *Client) Subscribe(id string) (chan *Message, error)

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(id string) error

type Connection

type Connection interface {
	Write(msg *Request) error
	Read() (*Message, error)
	Close() error
}

func DialHttpConnection

func DialHttpConnection(addr string) (Connection, error)

func DialWebsocketConnection

func DialWebsocketConnection(host string) (Connection, error)

type Error

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

type Message

type Message struct {
	ID      int64  `json:"id,omitempty"`
	Version string `json:"jsonrpc"`

	Method string          `json:"method,omitempty"`
	Params json.RawMessage `json:"params,omitempty"`

	Result json.RawMessage `json:"result,omitempty"`
	Error  *Error          `json:"error,omitempty"`
}

func (*Message) Reset

func (msg *Message) Reset()

type Request

type Request struct {
	ID      int64  `json:"id,omitempty"`
	Version string `json:"jsonrpc"`

	Method string        `json:"method"`
	Params []interface{} `json:"params,omitempty"`
}

func NewRequest

func NewRequest(method string, params ...interface{}) *Request

Jump to

Keyboard shortcuts

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