jsonrpc

package
v2.3.55 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "2.0"
)

Variables

View Source
var NewID = uuid.New
View Source
var NilID = uuid.Nil

Functions

func Params

func Params(params ...interface{}) interface{}

Types

type ClientRPC

type ClientRPC struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, opts ...Option) (client *ClientRPC)

func (*ClientRPC) Call

func (client *ClientRPC) Call(ctx context.Context, method string, params ...interface{}) (response *ResponseRPC, err error)

func (*ClientRPC) CallBatch

func (client *ClientRPC) CallBatch(ctx context.Context, requests RequestsRPC) (responses ResponsesRPC, err error)

func (*ClientRPC) CallBatchRaw

func (client *ClientRPC) CallBatchRaw(ctx context.Context, requests RequestsRPC) (responses ResponsesRPC, err error)

func (*ClientRPC) CallFor

func (client *ClientRPC) CallFor(ctx context.Context, out interface{}, method string, params ...interface{}) (err error)

func (*ClientRPC) CallRaw

func (client *ClientRPC) CallRaw(ctx context.Context, request *RequestRPC) (response *ResponseRPC, err error)

type CurlCommand

type CurlCommand struct {
	// contains filtered or unexported fields
}

func (*CurlCommand) String

func (c *CurlCommand) String() string

type HTTPError

type HTTPError struct {
	Code int
	// contains filtered or unexported fields
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type ID

type ID = uuid.UUID

type Option

type Option func(ops *options)

func AllowUnknownFields

func AllowUnknownFields(allowUnknownFields bool) Option

func HeaderFromCtx

func HeaderFromCtx(headers ...interface{}) Option

func Insecure

func Insecure() Option

func LogOnError

func LogOnError() Option

func LogRequest

func LogRequest() Option

type RPCError

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

func (*RPCError) Error

func (e *RPCError) Error() string

func (*RPCError) Raw

func (e *RPCError) Raw() (data json.RawMessage)

type RequestRPC

type RequestRPC struct {
	ID      ID          `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
	JSONRPC string      `json:"jsonrpc"`
}

func NewRequest

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

func NewRequestWithID

func NewRequestWithID(id ID, method string, params ...interface{}) *RequestRPC

type RequestsRPC

type RequestsRPC []*RequestRPC

type ResponseRPC

type ResponseRPC struct {
	ID      uuid.UUID       `json:"id"`
	JSONRPC string          `json:"jsonrpc"`
	Error   *RPCError       `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
}

func (*ResponseRPC) GetObject

func (responseRPC *ResponseRPC) GetObject(object interface{}) error

type ResponsesRPC

type ResponsesRPC []*ResponseRPC

func (ResponsesRPC) AsMap

func (res ResponsesRPC) AsMap() map[ID]*ResponseRPC

func (ResponsesRPC) GetByID

func (res ResponsesRPC) GetByID(id ID) *ResponseRPC

func (ResponsesRPC) HasError

func (res ResponsesRPC) HasError() bool

Jump to

Keyboard shortcuts

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