Documentation
¶
Overview ¶
Package server provides runtime support for implementing Cap'n Proto interfaces locally.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServer ¶
func IsServer(brand capnp.Brand) (_ interface{}, ok bool)
IsServer reports whether a brand returned by capnp.Client.Brand originated from Server.Brand, and returns the brand argument passed to New.
Example ¶
x := int(42) c := capnp.NewClient(server.New([]server.Method{}, x, nil, nil)) if brand, ok := server.IsServer(c.State().Brand); ok { fmt.Println("Client is a server, got brand:", brand) }
Output: Client is a server, got brand: 42
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call holds the state of an ongoing capability method call. A Call cannot be used after the server method returns.
func (*Call) Ack ¶
func (c *Call) Ack()
Ack is a function that is called to acknowledge the delivery of the RPC call, allowing other RPC methods to be called on the server. After the first call, subsequent calls to Ack do nothing.
Ack need not be the first call in a function nor is it required. Since the function's return is also an acknowledgment of delivery, short functions can return without calling Ack. However, since the server will not return an Answer until the delivery is acknowledged, failure to acknowledge a call before waiting on an RPC may cause deadlocks.
func (*Call) AllocResults ¶
AllocResults allocates the results struct. It is an error to call AllocResults more than once.
type Policy ¶
type Policy struct { // MaxConcurrentCalls is the maximum number of methods allowed to be // executing on a single Server simultaneously. Attempts to make more // calls than this limit will result in immediate error answers. // // If this is zero, then a reasonably small default is used. MaxConcurrentCalls int // AnswerQueueSize is the maximum number of methods allowed to be // enqueued on a single returned Answer while it is unresolved. // Attempts to enqueue more calls than this limit will result in // immediate error answers. // // If this is zero, then a reasonably small default is used. AnswerQueueSize int }
Policy is a set of behavioral parameters for a Server. They're not specific to a particular server and are generally set at an application level. Library functions are encouraged to accept a Policy from a caller instead of creating their own.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server is a locally implemented interface. It implements the capnp.ClientHook interface.
func New ¶
func New(methods []Method, brand interface{}, shutdown Shutdowner, policy *Policy) *Server
New returns a client hook that makes calls to a set of methods. If shutdown is nil then the server's shutdown is a no-op. The server guarantees message delivery order by blocking each call on the return or acknowledgment of the previous call. See Call.Ack for more details.
func (*Server) Brand ¶
func (srv *Server) Brand() capnp.Brand
Brand returns a value that will match IsServer.
type Shutdowner ¶
type Shutdowner interface {
Shutdown()
}
Shutdowner is the interface that wraps the Shutdown method.