jsonrpc

package
v3.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientCodec

func NewClientCodec(codec Codec) core.ClientCodec

NewClientCodec returns the ClientCodec.

func NewServiceCodec

func NewServiceCodec(codec Codec, options ...core.CodecOption) core.ServiceCodec

NewServiceCodec returns the ServiceCodec.

Types

type ClientCodec

type ClientCodec struct {
	Codec
	// contains filtered or unexported fields
}

func (*ClientCodec) Decode

func (c *ClientCodec) Decode(response []byte, context *core.ClientContext) (result []interface{}, err error)

func (*ClientCodec) Encode

func (c *ClientCodec) Encode(name string, args []interface{}, context *core.ClientContext) ([]byte, error)

type Codec

type Codec interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

type Error

type Error struct {
	Code    int64  `json:"code,omitempty"`
	Message string `json:"message"`
	Data    []byte `json:"data,omitempty"`
}

type Request

type Request struct {
	JSONRPC string                 `json:"jsonrpc"`
	ID      int64                  `json:"id"`
	Headers map[string]interface{} `json:"headers,omitempty"`
	Method  string                 `json:"method"`
	Params  []interface{}          `json:"params,omitempty"`
}

type Response

type Response struct {
	JSONRPC string                 `json:"jsonrpc"`
	ID      int64                  `json:"id"`
	Headers map[string]interface{} `json:"headers,omitempty"`
	Result  interface{}            `json:"result,omitempty"`
	Error   *Error                 `json:"error,omitempty"`
}

type ServiceCodec

type ServiceCodec struct {
	Codec
	// contains filtered or unexported fields
}

func (*ServiceCodec) Decode

func (c *ServiceCodec) Decode(request []byte, context *core.ServiceContext) (name string, args []interface{}, err error)

func (*ServiceCodec) Encode

func (c *ServiceCodec) Encode(result interface{}, context *core.ServiceContext) ([]byte, error)

Jump to

Keyboard shortcuts

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