Documentation ¶
Overview ¶
Package pubsub implements a publish-subscriber messaging system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("topic not found")
ErrNotFound is returned when the named topic does not exist.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { // ID identifies this message. ID string `json:"id,omitempty"` // Data is the actual data in the entry. Data []byte `json:"data"` // Labels represents the key-value pairs the entry is lebeled with. Labels map[string]string `json:"labels,omitempty"` }
Message defines a published message.
type Publisher ¶
type Publisher interface { // Create creates the named topic. Create(c context.Context, topic string) error // Publish publishes the message. Publish(c context.Context, topic string, message Message) error // Subscribe subscribes to the topic. The Receiver function is a callback // function that receives published messages. Subscribe(c context.Context, topic string, receiver Receiver) error // Remove removes the named topic. Remove(c context.Context, topic string) error }
Publisher defines a mechanism for communicating messages from a group of senders, called publishers, to a group of consumers.
Click to show internal directories.
Click to hide internal directories.