Documentation
¶
Overview ¶
Package pubsub provides a simple publish/subscribe mechanism for a generic type using a radix tree of topics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DuplicateSubscription ¶
type DuplicateSubscription struct{}
DuplicateSubscription is an error returned when a channel is already subscribed.
func (DuplicateSubscription) Error ¶
func (DuplicateSubscription) Error() string
Error implements the error interface.
type Interface ¶
type Interface[T any] interface { // Process starts the pubsub instance. It will block until the exit channel is closed. Process(exit <-chan struct{}) // Publish sends a value to all subscribers for any published value starting with the given topic. Any // subscribers that are not ready to receive the value will be skipped. Publish(v T, topic ...string) // Subscribe adds a subscriber channel for any published value starting with the given topic. Returns // DuplicateSubscription if the channel is already subscribed to the topic. Subscribe(ch chan<- T, topic ...string) error // Unsubscribe removes a subscriber channel for any published value starting with the given topic. This // should match the original channel passed to Subscribe. Does nothing if there is no subscriber. // The channel will be closed when it is unsubscribed. Unsubscribe(ch chan<- T, topic ...string) }
Interface is a simple publish/subscribe mechanism for a generic type using a radix tree of topics.
Click to show internal directories.
Click to hide internal directories.