rpc

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents an connection to a Json RPC server

func Dial

func Dial(socket string, path string, onConn onConnection) *Client

Dial initializes a background context and creates a new client for the given unix domain socket and API path

Currently the dial function is dedicated to establish a local unix domain socket connection using UNIX domain sockets based on websocket connection.

The client reconnects automatically if the connection is lost

func DialWithContext

func DialWithContext(ctx context.Context, socket string, path string, onConn onConnection) *Client

DialWithContext creates a new client to connect to the server

func (*Client) Call

func (c *Client) Call(method string, args interface{}, result interface{}) error

Call initializes a background context and performs a JSON-RPC call with the given arguments and unmarshals into result if no error occurred

The result must be a pointer so that package json can unmarshal into it. Nil object should not be passed into

future improvement: could deliver error message as well

func (*Client) CallWithContext

func (c *Client) CallWithContext(ctx context.Context, method string, args interface{}, result interface{}) error

CallWithContext performs a JSON-RPC call with the given arguments and unmarshals into result if no error occurred

func (*Client) Close

func (c *Client) Close()

Close terminates the connection between the client and the websocket server, aborting any in-flight calls

func (*Client) IsEmpty

func (c *Client) IsEmpty() bool

IsEmpty return true while the client has been initialized yet

Jump to

Keyboard shortcuts

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