Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster[T any] struct { // contains filtered or unexported fields }
Broadcaster reads from one chan and writes to many subscribed chans, Subscribe will return a token, and a receive-only chan for reads, Unsubscribe must be called with the token to close the subscription, if not called, the system will not shut down gracefully Broadcast must be called in a separate long-running goroutine, this will not return even if there are no subscribers to relay msgs to, Broadcast will only return once shutdown is initiated
func NewBroadcaster ¶
func NewBroadcaster[T any]() *Broadcaster[T]
func (*Broadcaster[T]) Broadcast ¶
func (b *Broadcaster[T]) Broadcast(shtdwnCtx context.Context)
func (*Broadcaster[T]) Get ¶
func (b *Broadcaster[T]) Get() T
func (*Broadcaster[T]) Subscribe ¶
func (b *Broadcaster[T]) Subscribe() (int, <-chan T)
func (*Broadcaster[T]) Unsubscribe ¶
func (b *Broadcaster[T]) Unsubscribe(token int)
func (*Broadcaster[T]) Write ¶
func (b *Broadcaster[T]) Write(v T)
Click to show internal directories.
Click to hide internal directories.