Documentation
¶
Overview ¶
Package batch provides a generic worker that accumulates items and flushes them in batches.
A batch is flushed when it reaches the configured size or when the flush interval elapses, whichever comes first. The caller supplies a Writer that persists each flushed batch (bulk insert, API call, …).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Worker ¶
type Worker[T any] interface { // Start starts worker Start(ctx context.Context) // Write calls to pass a single item to be written Write(ctx context.Context, item *T) // Close closes worker Close(ctx context.Context) }
Worker allows writing data in a batch manner events to write fire either by time interval or by number of items waiting to be written
func NewBatchWorker ¶
Click to show internal directories.
Click to hide internal directories.