batcher

package
v0.0.0-...-d17e12a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchBuilder

type BatchBuilder interface {
	// Build builds the batch payloads
	// it's possible that not all input payloads can be combined into one
	Build(input [][]byte, maxBytes int) [][]byte
}

BatchBuilder defines builder interface

type BatchHandler

type BatchHandler func(context.Context, []byte) error

BatchHandler defines handler

type Batcher

type Batcher struct {
	// contains filtered or unexported fields
}

Batcher implements buffered batcher

func NewBatcher

func NewBatcher(
	bb BatchBuilder,
	bh BatchHandler,
	d time.Duration,
	maxBytes int) *Batcher

NewBatcher returns new instance

func (*Batcher) Add

func (bt *Batcher) Add(p []byte)

Add adds single payload to batch buffer

func (*Batcher) Batch

func (bt *Batcher) Batch()

Batch processes buffered payloads

func (*Batcher) Exit

func (bt *Batcher) Exit()

Exit stops the internal ticker

func (*Batcher) Reset

func (bt *Batcher) Reset(d time.Duration, maxBytes int)

Reset applies configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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