rpc

package
v0.0.0-...-5ed304f Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

func (*Error) Error

func (err *Error) Error() string

type Message

type Message struct {
	ID      json.RawMessage   `json:"id"`
	JSONRPC string            `json:"jsonrpc"`
	Method  string            `json:"method"`
	Worker  string            `json:"worker,omitempty"`
	Params  []json.RawMessage `json:"params"`
	Result  json.RawMessage   `json:"result"`
	Error   *Error            `json:"error,omitempty"`
}

func (*Message) ToRequest

func (m *Message) ToRequest() *Request

func (*Message) ToResponse

func (m *Message) ToResponse() *Response

type Request

type Request struct {
	HostID  string            `json:"-"`
	ID      json.RawMessage   `json:"id"`
	JSONRPC string            `json:"jsonrpc"`
	Method  string            `json:"method"`
	Worker  string            `json:"worker,omitempty"`
	Params  []json.RawMessage `json:"params,omitempty"`
}

func MustNewRequest

func MustNewRequest(method string, inputs ...interface{}) *Request

func NewRequest

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

func NewRequestWithHostID

func NewRequestWithHostID(hostID, method string, inputs ...interface{}) (*Request, error)

func NewRequestWithID

func NewRequestWithID(rawID interface{}, method string, inputs ...interface{}) (*Request, error)

type Response

type Response struct {
	HostID  string          `json:"-"`
	ID      json.RawMessage `json:"id"`
	JSONRPC string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result"`
	Error   *Error          `json:"error,omitempty"`
}

func ExecRPC

func ExecRPC(url string, req *Request) (*Response, error)

func ExecRPCBulk

func ExecRPCBulk(url string, requests []*Request) ([]*Response, error)

func NewResponse

func NewResponse(id json.RawMessage, result interface{}) (*Response, error)

func NewResponseFromJSON

func NewResponseFromJSON(id, result json.RawMessage) *Response

func NewResponseWithError

func NewResponseWithError(id json.RawMessage, code int, message string) *Response

type ResponseForced

type ResponseForced struct {
	Response
	Error *Error `json:"error"`
}

func NewResponseForced

func NewResponseForced(id json.RawMessage, result interface{}) (*ResponseForced, error)

func NewResponseForcedFromJSON

func NewResponseForcedFromJSON(id, result json.RawMessage) *ResponseForced

Jump to

Keyboard shortcuts

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