Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher[K comparable, T any] struct { // contains filtered or unexported fields }
Batcher is a one to many event batcher. It batches events and sends them to the added event channel subscribers. Events are sent to the channels after the interval has elapsed. If events with the same key are received within the interval, the timer is reset.
func New ¶
func New[K comparable, T any](opts Options) *Batcher[K, T]
New creates a new Batcher with the given interval and key type.
func (*Batcher[K, T]) Batch ¶
func (b *Batcher[K, T]) Batch(key K, value T)
Batch adds the given key to the batcher. If an event for this key is already active, the timer is reset. If the batcher is closed, the key is silently dropped.
Click to show internal directories.
Click to hide internal directories.