rpc

package
v2.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package rpc implements the Cap'n Proto RPC protocol.

Example
Output:

Results: 7 30

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrConnClosed = errors.New("rpc: connection closed")
)

Errors

Functions

This section is empty.

Types

type Abort

type Abort Exception

An Abort is a hang-up by a remote vat.

func (Abort) Error

func (a Abort) Error() string

Error returns the exception's reason.

type Conn

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

A Conn is a connection to another Cap'n Proto vat. It is safe to use from multiple goroutines.

func NewConn

func NewConn(t Transport, options ...ConnOption) *Conn

NewConn creates a new connection that communicates on c. Closing the connection will cause c to be closed.

func (*Conn) Bootstrap

func (c *Conn) Bootstrap(ctx context.Context) capnp.Client

Bootstrap returns the receiver's main interface.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) Wait

func (c *Conn) Wait() error

Wait waits until the connection is closed or aborted by the remote vat. Wait will always return an error, usually ErrConnClosed or of type Abort.

type ConnOption

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

A ConnOption is an option for opening a connection.

func MainInterface

func MainInterface(client capnp.Client) ConnOption

MainInterface specifies that the connection should use client when receiving bootstrap messages. By default, all bootstrap messages will fail.

func SendBufferSize

func SendBufferSize(numMsgs int) ConnOption

SendBufferSize sets the number of outgoing messages to buffer on the connection. This is in addition to whatever buffering the connection's transport performs.

type Exception

type Exception struct {
	rpccapnp.Exception
}

An Exception is a Cap'n Proto RPC error.

func (Exception) Error

func (e Exception) Error() string

Error returns the exception's reason.

type Transport

type Transport interface {
	// SendMessage sends msg.
	SendMessage(ctx context.Context, msg rpccapnp.Message) error

	// RecvMessage waits to receive a message and returns it.
	// Implementations may re-use buffers between calls, so the message is
	// only valid until the next call to RecvMessage.
	RecvMessage(ctx context.Context) (rpccapnp.Message, error)

	// Close releases any resources associated with the transport.
	Close() error
}

Transport is the interface that abstracts sending and receiving individual messages of the Cap'n Proto RPC protocol.

func StreamTransport

func StreamTransport(rwc io.ReadWriteCloser) Transport

StreamTransport creates a transport that sends and receives messages by serializing and deserializing unpacked Cap'n Proto messages. Closing the transport will close the underlying ReadWriteCloser.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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