feed

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Notify

func Notify(t *Tick)

Notify ticks every subscriber of a tick feed.

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

func New[T any](n int) *Feed[T]

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]) Len

func (f *Feed[T]) Len() int

Len is the subscriber count.

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

func (f *Feed[T]) SubscribeContext(ctx context.Context) <-chan T

SubscribeContext is Subscribe until ctx ends, when the channel closes.

type Tick

type Tick = Feed[struct{}]

Tick is a coalescing change feed: a pending tick absorbs the next.

func NewTick

func NewTick() *Tick

NewTick is a coalescing tick feed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL