Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPubSub ¶
func NewPubSub[K comparable, E any](getKey func(E) K, opts ...Option) queue.PubSub[K, E]
NewPubSub returns an in-memory implementation of the Publish–Subscribe pattern.
The getKey function extracts a routing key from messages to determine which subscribers receive them.
Example:
pb := NewPubSub(func(msg *MyMessage) string { return msg.Topic })
go pb.Start(ctx)
pb.Pub(ctx, &MyMessage{Topic: "news", Content: "Hello"})
Types ¶
type Option ¶
type Option func(o *newOption)
func WithPubCapacity ¶
WithPubCapacity sets the capacity of the publisher channel. Larger values allow more messages to be buffered before blocking publishers.
func WithSubCapacity ¶
WithSubCapacity sets the capacity of each subscriber channel. Larger values allow more messages to be buffered per subscriber before dropping messages.
Click to show internal directories.
Click to hide internal directories.