jsonrpc

Imports

Imports #

"encoding/json"
"fmt"
"io"
"net"
"net/rpc"
"sync"
"encoding/json"
"errors"
"io"
"net/rpc"
"sync"

Constants & Variables

errMissingParams var #

var errMissingParams = *ast.CallExpr

null var #

var null = *ast.CallExpr

Structs

clientCodec struct #

type clientCodec struct {
dec *json.Decoder
enc *json.Encoder
c io.Closer
req clientRequest
resp clientResponse
mutex sync.Mutex
pending map[uint64]string
}

clientRequest struct #

type clientRequest struct {
Method string `json:"method"`
Params [1]any `json:"params"`
Id uint64 `json:"id"`
}

clientResponse struct #

type clientResponse struct {
Id uint64 `json:"id"`
Result *json.RawMessage `json:"result"`
Error any `json:"error"`
}

serverCodec struct #

type serverCodec struct {
dec *json.Decoder
enc *json.Encoder
c io.Closer
req serverRequest
mutex sync.Mutex
seq uint64
pending map[uint64]*json.RawMessage
}

serverRequest struct #

type serverRequest struct {
Method string `json:"method"`
Params *json.RawMessage `json:"params"`
Id *json.RawMessage `json:"id"`
}

serverResponse struct #

type serverResponse struct {
Id *json.RawMessage `json:"id"`
Result any `json:"result"`
Error any `json:"error"`
}

Functions

Close method #

func (c *serverCodec) Close() error

Close method #

func (c *clientCodec) Close() error

Dial function #

Dial connects to a JSON-RPC server at the specified network address.

func Dial(network string, address string) (*rpc.Client, error)

NewClient function #

NewClient returns a new [rpc.Client] to handle requests to the set of services at the other end of the connection.

func NewClient(conn io.ReadWriteCloser) *rpc.Client

NewClientCodec function #

NewClientCodec returns a new [rpc.ClientCodec] using JSON-RPC on conn.

func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

NewServerCodec function #

NewServerCodec returns a new [rpc.ServerCodec] using JSON-RPC on conn.

func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec

ReadRequestBody method #

func (c *serverCodec) ReadRequestBody(x any) error

ReadRequestHeader method #

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error

ReadResponseBody method #

func (c *clientCodec) ReadResponseBody(x any) error

ReadResponseHeader method #

func (c *clientCodec) ReadResponseHeader(r *rpc.Response) error

ServeConn function #

ServeConn runs the JSON-RPC server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement.

func ServeConn(conn io.ReadWriteCloser)

WriteRequest method #

func (c *clientCodec) WriteRequest(r *rpc.Request, param any) error

WriteResponse method #

func (c *serverCodec) WriteResponse(r *rpc.Response, x any) error

reset method #

func (r *serverRequest) reset()

reset method #

func (r *clientResponse) reset()

Generated with Arrow