Documentation ¶
Overview ¶
Package Topic provides a buffered channel with dynamic fanout size. Unlike the normal Go channels, messages sent to a Topic are *duplicated* to all it's receivers. Incoming messages are queued in-memory when a receiver is not ready. Users can add/remove receivers from a topic dynamically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Receiver ¶
type Receiver[T any] struct { // contains filtered or unexported fields }
func (*Receiver[T]) Unsubscribe ¶
func (r *Receiver[T]) Unsubscribe()
Unsubscribe removes a receiver from a topic. Buffered messages that were not yet received will be discarded.
type Topic ¶
type Topic[T any] struct { // contains filtered or unexported fields }
Topic implements a buffered channel with dynamic fanout.
func (*Topic[T]) Close ¶
Close destroys the topic. Blocking operations will return with os.ErrClosed error. All receivers are forcibly unsubscribed. Caller is blocked till all background goroutines complete.