rpc

package module
v0.0.0-...-e50759e Latest Latest
Warning

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

Go to latest
Published: May 17, 2018 License: MIT Imports: 10 Imported by: 0

README

rpc

A stupid simple directionless RPC for Go.

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 a client.

func NewClient

func NewClient(conn net.Conn) (*Client, error)

NewClient returns a new client on the given connection.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying client connection.

func (*Client) Do

func (c *Client) Do(event string, payload interface{}) (interface{}, error)

Do performs a blocking request that blocks until the handler on the remote end responds. The value of the response is returned. Errors from the remote end are moved into the second return argument additionally.

func (*Client) Fire

func (c *Client) Fire(event string, payload interface{}) error

Fire fires an event with the given payload asynchronously.

func (*Client) On

func (c *Client) On(event string, handler Handler)

On registers a handler for handling an event.

func (*Client) Receive

func (c *Client) Receive() error

Receive runs the receive loop to process incoming packets. It returns when the connection dies, and a new client will need to be spawned.

type Handler

type Handler func(payload interface{}) interface{}

Handler represents the handler used for receiving events.

type Packet

type Packet struct {
	Event       string
	ID          string
	ExpectReply bool
	Payload     interface{}
}

Packet represents a packet that is serialized for lidar use.

Jump to

Keyboard shortcuts

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