Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBufferSizeTooLarge = errors.New("buffer size too large")
ErrBufferSizeTooLarge is returned when the buffer size for a topic exceeds the maximum allowed size as defined in the runtime options.
var ErrInvalidTopicName = errors.New("invalid topic name")
ErrInvalidTopicName is returned when a topic name is invalid.
var ErrTopicClosed = errors.New("topic is closed")
ErrTopicClosed is returned when publishing to a closed topic.
Functions ¶
This section is empty.
Types ¶
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
func (*PubSub) CreateTopic ¶
CreateTopic creates a new topic with the given name and buffer size. Returns an error if the topic already exists or if the buffer size exceeds the maximum allowed size.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
A Subscription represents a subscription to a topic. Every message is delivered to every subscription exactly once. Multiple consumers can read from the same subscription's Data() channel.
func (*Subscription) Close ¶
func (s *Subscription) Close()
Close closes the subscription for every consumer. Safe to call multiple times per subscription (although all subscribers will stop receiving messages once called once).
func (*Subscription) Data ¶
func (s *Subscription) Data() <-chan any
Data returns the channel on which the subscription receives data. Consumers should range over this channel to receive messages. The channel is closed when the subscription or its associated topic are closed.