notifier

package
v0.0.0-...-fa598ba Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

Notifier is the sending endpoint of an event notification mechanism. It broadcasts a stream of events to a number of receivers.

func NewNotifier

func NewNotifier[T any]() *Notifier[T]

NewNotifier creates a new Notifier.

func (*Notifier[T]) Close

func (n *Notifier[T]) Close()

Close closes the notifier.

func (*Notifier[T]) Flush

func (n *Notifier[T]) Flush(ctx context.Context) error

Flush flushes all pending notifications. Note that for Flush to work as expected, a quiescent period is required, i.e. you should not send more events until Flush returns.

func (*Notifier[T]) NewReceiver

func (n *Notifier[T]) NewReceiver() *Receiver[T]

NewReceiver creates a new Receiver associated with the given Notifier.

func (*Notifier[T]) Notify

func (n *Notifier[T]) Notify(event T)

Notify sends a new notification event.

type Receiver

type Receiver[T any] struct {
	// C is a channel to read the events from.
	// Note that it is part of the public interface of this package.
	C chan T
	// contains filtered or unexported fields
}

Receiver is the receiving endpoint of a single-producer-multiple-consumer notification mechanism.

func (*Receiver[T]) Close

func (r *Receiver[T]) Close()

Close closes the receiver

Jump to

Keyboard shortcuts

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