Documentation ¶
Overview ¶
Package stream offers an abstraction layer for stream-processing platforms, such as NATS streaming.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PubWithContext ¶
PubWithContext returns a copy of parent in which the `Pub` is stored
func SubWithContext ¶
SubWithContext returns a copy of parent in which the `Sub` is stored
Types ¶
type Pub ¶
type Pub interface { // Publish publishes data to the channel ch // Publish(ctx context.Context, ch string, data []byte) error Publish(ctx context.Context, ch string, data []byte) error }
Pub is the publish interface
func PubFromContext ¶
PubFromContext returns a `Pub` instance associated with `ctx`, or the local `Pub` if no instance could be found.
type Stream ¶
type Stream interface { Pub Sub // Start does the initialisation work to bootstrap a Stream adapter. // For example, this function may open a connection, start an event loop, etc. Start(ctx context.Context) error // Drain signals to the Stream client/server that inbound messages should // no longer be accepted, but outbound messages can still be delivered. Drain() // Close closes the client/server for both inbound/outbound messages Close() error }
func FromContext ¶
FromContext returns a `Stream` instance associated with `ctx`, or the local `Sub` if no instance could be found.
type Sub ¶
type Sub interface { // Subscribe subscribes the message handler h to the channel ch. // All subscriptions with the same q will form a queue group. // Each message will be delivered to only one subscriber per queue group. // Subscribe(q, ch string, h MsgHandler) error Subscribe(q, ch string, f MsgHandler, opts ...SubscriptionOption) (Subscription, error) }
Sub is the subscribe interface
func SubFromContext ¶
SubFromContext returns a `Sub` instance associated with `ctx`, or the local `Sub` if no instance could be found.
type Subscription ¶
type Subscription interface { // Unsubscribe removes interest in the subscription. // For durables, it means that the durable interest is also removed from // the server. Restarting a durable with the same name will not resume // the subscription, it will be considered a new one. Unsubscribe() error }
Subscription represents a subscription to the streaming platform
type SubscriptionOption ¶
type SubscriptionOption interface{}