Documentation
¶
Overview ¶
Package feed is the in-process change fan-out the services share: every subscriber gets its own buffered channel, publishing never blocks on a slow or departed reader (a full buffer drops the value; tick feeds coalesce), and unsubscribing closes the channel so the reader's range loop ends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Feed ¶
type Feed[T any] struct { // contains filtered or unexported fields }
Feed fans values out to its subscribers. The zero value is a coalescing feed (one-slot buffers), ready to use.
func New ¶
New is a feed whose subscriber channels buffer n values; n = 1 with struct{} values is a coalescing tick feed.
func (*Feed[T]) Close ¶
func (f *Feed[T]) Close()
Close closes every subscriber's channel; later subscriptions come back closed.
func (*Feed[T]) Publish ¶
func (f *Feed[T]) Publish(v T)
Publish offers v to every subscriber without blocking.
func (*Feed[T]) Subscribe ¶
func (f *Feed[T]) Subscribe() (<-chan T, func())
Subscribe registers a reader. stop unregisters and closes the channel; it is safe to call more than once. On a closed feed the channel comes back closed.
func (*Feed[T]) SubscribeContext ¶
SubscribeContext is Subscribe until ctx ends, when the channel closes.