server

package
v2.12.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package server provides runtime support for implementing Cap'n Proto interfaces locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ack

func Ack(opts capnp.CallOptions)

Ack acknowledges delivery of a server call, allowing other methods to be called on the server. It is intended to be used inside the implementation of a server function. Calling Ack on options that aren't from a server method implementation is a no-op.

Example:

func (my *myServer) MyMethod(call schema.MyServer_myMethod) error {
	server.Ack(call.Options)
	// ... do long-running operation ...
	return nil
}

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 clients will not return an Answer until the delivery is acknowledged, it is advisable to ack early.

func New

func New(methods []Method, closer Closer) capnp.Client

New returns a client that makes calls to a set of methods. If closer is nil then the client's Close is a no-op. The server guarantees message delivery order by blocking each call on the return or acknowledgment of the previous call. See the Ack function for more details.

Types

type Closer

type Closer interface {
	Close() error
}

Closer is the interface that wraps the Close method.

type Func

type Func func(ctx context.Context, options capnp.CallOptions, params, results capnp.Struct) error

A Func is a function that implements a single method.

type Method

type Method struct {
	capnp.Method
	Impl        Func
	ResultsSize capnp.ObjectSize
}

A Method describes a single method on a server object.

Jump to

Keyboard shortcuts

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