Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JoinServer ¶
type JoinServer interface {
Join(context.Context, api.Router_join) error
}
JoinServer is an interface that allows alternate server implementations for Joiner. The default implementation is Router. See: NewJoiner.
type Router ¶
Router is a client capability that confers the right to join pubsub topics. It is the dual to Router.
func NewJoiner ¶
func NewJoiner(s JoinServer) Router
NewJoiner returns a Joiner (a capability client) from a JoinServer interface. Most users will prefer to instantiate a Joiner directly by calling the Router.PubSub method.
NewJoiner allows callers to supply alternate implementations of JoinServer. This is most commonly used in unit-testing.
type Server ¶
type Server struct {
Log log.Logger
TopicJoiner TopicJoiner
// contains filtered or unexported fields
}
Server for the pubsub capability.
type Subscription ¶
Subscription is a stateful iterator over a stream of topic messages.
func (Subscription) Err ¶
func (sub Subscription) Err() error
Err returns the first non-nil error encountered by the subscription. If there is no error, Err() returns nil.
func (Subscription) Next ¶
func (sub Subscription) Next() []byte
Next blocks until the next message is received, and returns it. It returns nil when the subscription is canceled.
type Topic ¶
Topic is the handle for a pubsub topic. It is used to publish to the topic, and to manage subscriptions.
func NewTopic ¶
func NewTopic(s TopicServer) Topic
NewTopic returns a Joiner (a capability client) from a JoinServer interface. This is most commonly used in unit-testing.
func (Topic) Name ¶
Name returns the name of the pubsub topic. This is guaranteed never to change, so callers MAY cache results locally.
func (Topic) Publish ¶
Publish a message asynchronously. The first error encountered will be returned by all subsequent calls to Publish().
func (Topic) Subscribe ¶
func (t Topic) Subscribe(ctx context.Context) (Subscription, capnp.ReleaseFunc)
Subscribe to the topic. Callers MUST call the provided ReleaseFunc when finished with the subscription, or a resource leak will occur.
type TopicJoiner ¶
TopicJoiner can join libp2p pubsub topics. It is a low- level interface provided to Router.
type TopicServer ¶
type TopicServer interface {
Name(context.Context, api.Topic_name) error
Publish(context.Context, api.Topic_publish) error
Subscribe(context.Context, api.Topic_subscribe) error
}
TopicServer is an interface that allows alternate server implementations for Topic. The default implementation is unexported. See NewTopic.