rpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: GPL-2.0 Imports: 6 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 {
	// contains filtered or unexported fields
}

func (*Error) Error

func (err *Error) Error() string

func (*Error) Unwrap

func (err *Error) Unwrap() error

type RPC

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

func NewRPC

func NewRPC(writer io.WriteCloser, reader io.Reader, logger *zap.SugaredLogger) *RPC

NewRPC creates and returns an RPC instance

func (*RPC) Call

func (r *RPC) Call(method string, params json.RawMessage) (json.RawMessage, error)

Call sends a request with given parameters. Returns the Response.Result or an error.

Two different kinds of error can be returned:

  • rpc.Error: Communication failed and future calls on this instance won't work and a new *RPC has to be created.
  • Response.Error: The response contains an error (that's non-fatal for the RPC object).

func (*RPC) Close

func (r *RPC) Close() error

Close closes the RPC.writer. All further calls to Call lead to an error. The Process will be terminated as soon as all pending requests have been processed.

func (*RPC) Done

func (r *RPC) Done() <-chan struct{}

Done sends when the processResponsesErrCh has been closed. processResponsesErrCh is closed when decoder fails to read

func (*RPC) Err

func (r *RPC) Err() error

Err returns a non-nil error, If Done sends. Otherwise, nil is returned

type Request

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

type Response

type Response struct {
	Result json.RawMessage `json:"result,omitempty"`
	Error  string          `json:"error,omitempty"`
	Id     uint64          `json:"id"`
}

Jump to

Keyboard shortcuts

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