Documentation
¶
Overview ¶
Package rpc implements the Cap'n Proto RPC protocol.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrConnClosed = errors.New("rpc: connection closed")
)
Errors
Functions ¶
This section is empty.
Types ¶
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.
type ConnOption ¶
type ConnOption struct {
// contains filtered or unexported fields
}
A ConnOption is an option for opening a connection.
func BootstrapFunc ¶
func BootstrapFunc(f func(context.Context) (capnp.Client, error)) ConnOption
BootstrapFunc specifies the function to call to create a capability for handling bootstrap messages. This function should not make any RPCs or block.
func ConnLog ¶
func ConnLog(log Logger) ConnOption
ConnLog sets the connection's log to the given Logger, which may be nil to disable logging. By default, logs are sent to the standard log package.
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. The client will be closed when the connection is closed.
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 Logger ¶
type Logger interface { Infof(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) }
A Logger records diagnostic information and errors that are not associated with a call. The arguments passed into a log call are interpreted like fmt.Printf. They should not be held onto past the call's return.
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.