feed

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tee

func Tee[T any](sub *Subscription[T], f *Feed[T])

Tee forwards all values received from sub to f. It stops tee-ing values when sub is unsubscribed.

Types

type Feed

type Feed[T any] struct {
	// contains filtered or unexported fields
}

func New

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

func (*Feed[T]) Send

func (f *Feed[T]) Send(v T)

Send broadcasts v to all subscribers. Send will skip subscribers that block. Subscribers risk reading stale data if they wait a long time before calling Recv.

func (*Feed[T]) Subscribe

func (f *Feed[T]) Subscribe() *Subscription[T]

Subscribe returns a new subscription that skip emitting an event if the buffer is full.

func (*Feed[T]) SubscribeKeepLast added in v0.13.3

func (f *Feed[T]) SubscribeKeepLast() *Subscription[T]

SubscribeKeepLast returns a new subscription that drop the oldest event when the buffer is full to ensure that the last event is always available.

type Subscription

type Subscription[T any] struct {
	// contains filtered or unexported fields
}

func (*Subscription[T]) Recv

func (s *Subscription[T]) Recv() <-chan T

func (*Subscription[T]) Unsubscribe

func (s *Subscription[T]) Unsubscribe()

Jump to

Keyboard shortcuts

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