pubsub

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

type PubSub interface {
	// Publish publishes the object to the channel by name
	Publish(channel string, obj interface{}) error
	// PublishN publishes the object to the channel by name to the first N subscribers of the channel
	PublishN(channel string, obj interface{}, n int) error
	// Subscribe subscribes to the given channel until the context is cancelled
	Subscribe(ctx context.Context, channel string, handler func(obj interface{})) error
	// Subscribe subscribes to the given channel until it receives N messages or the context is cancelled
	SubscribeN(ctx context.Context, channel string, n int, handler func(msg interface{})) error
	// SubscribeUntil subscribes to the given channel until the decider returns false for the first time. The subscription breaks when the routine's context is cancelled or the decider returns false.
	SubscribeUntil(ctx context.Context, channel string, decider func() bool, handler func(msg interface{})) error
	// SubscribeWhile subscribes to the given channel while the decider returns true. The subscription breaks when the routine's context is cancelled.
	SubscribeWhile(ctx context.Context, channel string, decider func() bool, handler func(msg interface{})) error
	// SubscribeFilter subscribes to the given channel with the given filter
	SubscribeFilter(ctx context.Context, channel string, filter func(msg interface{}) bool, handler func(msg interface{})) error
	Close()
}

PubSub is used to asynchronously pass messages between routines.

func NewPubSub

func NewPubSub() PubSub

Jump to

Keyboard shortcuts

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