Documentation ¶
Overview ¶
batcher is a package that provides a simple batching mechanism the buffer can be configured with a max capacity and a flush interval the buffer will invoke a callback function when the buffer is full or the flush interval is reached
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher[T any] struct { // contains filtered or unexported fields }
Batcher is a batcher for any type of data
type BatcherOption ¶ added in v0.0.39
BatcherOption is the option for the batcher
func WithFlushCallback ¶ added in v0.0.39
func WithFlushCallback[T any](fn FlushCallback[T]) BatcherOption[T]
WithFlushCallback sets the flush callback of the batcher
func WithFlushInterval ¶ added in v0.0.39
func WithFlushInterval[T any](flushInterval time.Duration) BatcherOption[T]
WithFlushInterval sets the optional flush interval of the batcher
func WithMaxCapacity ¶ added in v0.0.39
func WithMaxCapacity[T any](maxCapacity int) BatcherOption[T]
WithMaxCapacity sets the max capacity of the batcher
type FlushCallback ¶
type FlushCallback[T any] func([]T)
FlushCallback is the callback function that will be called when the batcher is full or the flush interval is reached
Click to show internal directories.
Click to hide internal directories.