Documentation
¶
Overview ¶
Package transport defines an interface for sending and receiving rpc messages.
In addition to the implementations defined here, one of the developers maintains a websocket-backed implementation as a separate module:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface { Encode(*capnp.Message) error Decode() (*capnp.Message, error) // Mark a message previously returned by Decode as no longer needed. The // Codec may re-use the space for future messages. ReleaseMessage(*capnp.Message) Close() error }
A Codec is responsible for encoding and decoding messages from a single logical stream.
type Transport ¶
type Transport interface { // NewMessage allocates a new message to be sent over the transport. // The caller must call the release function when it no longer needs // to reference the message. Calling the release function more than once // has no effect. Before releasing the message, send may be called at most // once to send the mssage. // // Messages returned by NewMessage must have a nil CapTable. // When the returned ReleaseFunc is called, any clients in the message's // CapTable will be released. // // The Arena in the returned message should be fast at allocating new // segments. The returned ReleaseFunc MUST be safe to call concurrently // with subsequent calls to NewMessage. NewMessage() (_ rpccp.Message, send func() error, _ capnp.ReleaseFunc, _ error) // RecvMessage receives the next message sent from the remote vat. // The returned message is only valid until the release function is // called. The release function may be called concurrently with // RecvMessage or with any other release function returned by RecvMessage. // // Messages returned by RecvMessage must have a nil CapTable. // When the returned ReleaseFunc is called, any clients in the message's // CapTable will be released. // // The Arena in the returned message should not fetch segments lazily; // the Arena should be fast to access other segments. RecvMessage() (rpccp.Message, capnp.ReleaseFunc, error) // Close releases any resources associated with the transport. If there // are any outstanding calls to NewMessage, a returned send function, // or RecvMessage, they will be interrupted and return errors. Close() error }
A Transport sends and receives Cap'n Proto RPC messages to and from another vat.
It is safe to call NewMessage and its returned functions concurrently with RecvMessage.
func New ¶
New creates a new transport that uses the supplied codec to read and write messages across the wire.
func NewPackedStream ¶
func NewPackedStream(rwc io.ReadWriteCloser) Transport
NewPackedStream creates a new transport that uses a packed encoding.
See: NewStream.
func NewStream ¶
func NewStream(rwc io.ReadWriteCloser) Transport
NewStream creates a new transport that reads and writes to rwc. Closing the transport will close rwc.
rwc's Close method must interrupt any outstanding IO, and it must be safe to call rwc.Read and rwc.Write concurrently.