channels

package
v0.474.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterContext

func IterContext[T any](ctx context.Context, ch <-chan T) iter.Seq[T]

IterContext returns an iterator that iterates over the channel until the channel is closed or the context cancelled.

Check ctx.Err() != nil to detect if the context was cancelled.

Types

type Notifier added in v0.421.0

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier helps to notify multiple subscribers that an event has occurred.

Unlike pubsub.Topic, notifier drops messages if the subscribers are not processing them fast enough. As the messages do not carry payload, we are safe to do so.

func NewNotifier added in v0.421.0

func NewNotifier(ctx context.Context) *Notifier

NewNotifier creates a new Notifier instance.

The returned Notifier will automatically close all subscribers when the context is cancelled.

func (*Notifier) Notify added in v0.421.0

func (b *Notifier) Notify(ctx context.Context)

Notify all subscribers.

func (*Notifier) Subscribe added in v0.421.0

func (b *Notifier) Subscribe(ctx context.Context) <-chan struct{}

Subscribe to the notifier.

The returned channel will be closed when the notifier context is cancelled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳