Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher[T key] 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 (*Batcher[T]) Batch ¶
func (b *Batcher[T]) Batch(key 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.
func (*Batcher[T]) Close ¶
func (b *Batcher[T]) Close()
Close closes the batcher. It blocks until all events have been sent to the subscribers. The batcher will be a no-op after this call.
func (*Batcher[T]) Subscribe ¶
func (b *Batcher[T]) Subscribe(eventCh ...chan<- struct{})
Subscribe adds a new event channel subscriber. If the batcher is closed, the subscriber is silently dropped.
func (*Batcher[T]) WithClock ¶ added in v0.12.1
func (b *Batcher[T]) WithClock(clock clock.WithDelayedExecution)
WithClock sets the clock used by the batcher. Used for testing.