rpc

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAddress is the network address used by the rpc server if none is given.
	DefaultAddress = "127.0.0.1:0"
)

Variables

View Source
var (
	InstancePidFile = "pid"
)

Functions

func Call

func Call(ctx context.Context, addr, method string, params interface{}) (map[string]interface{}, error)

Call initiates a JSON-RPC call to a given rpc server address, using the specified method and waits for the response.

func CallById

func CallById(context context.Context, id, method string, params interface{}) (map[string]interface{}, error)

CallById returns the response of a remote procedure call made against another mole instance, given its id or alias.

func Register

func Register(name string, method Method)

Register adds a new method that can be called remotely.

func Show

func Show(context context.Context, id string) (map[string]interface{}, error)

Show returns runtime information about a mole instance, given its alias or id.

func ShowAll

func ShowAll(context context.Context) ([]map[string]interface{}, error)

ShowAll returns runtime information about all instaces of mole running on the system.

func Start

func Start(address string) (net.Addr, error)

Start initializes the jsonrpc 2.0 server which will be waiting for connections on a random port.

Types

type Handler

type Handler struct{}

Handler handles JSON-RPC requests and notifications.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request)

Handle manages JSON-RPC requests and notifications, executing the requested method and responding back to the client when needed.

type Method

type Method func(params interface{}) (json.RawMessage, error)

Method represents a procedure that can be called remotely.

Jump to

Keyboard shortcuts

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