rpcp

package module
v0.0.0-...-65dc30c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 12 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{}, result interface{}) error

Do performs a blocking request that blocks until the handler on the remote end responds. The value of the response is returned.

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 interface{}

Handler represents the handler used for receiving events.

type Packet

type Packet struct {
	Event       string             `msgpack:"v"`
	ID          string             `msgpack:"i"`
	Payload     msgpack.RawMessage `msgpack:"p"`
	IsError     bool               `msgpack:"e"`
	ExpectReply bool               `msgpack:"r"`
}

Packet represents a packet that is sent over the wire.

Jump to

Keyboard shortcuts

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