batch

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(ctx context.Context, items []interface{}) []bool

type Writer

type Writer struct {
	Handler Callback
	// contains filtered or unexported fields
}

Writer allows to buffer some items and call the Handler function either when the buffer is full or the timeout is reached. There will also be support for concurrency for high volume. The handler function is supposed to return an array of booleans to indicate whether the transfer was successful or not. It can be replaced with status codes in the future to differentiate I/O errors, rate limiting, authorization issues.

func NewWriter

func NewWriter(cfg WriterConfig, cb Callback) *Writer

func (*Writer) Start

func (w *Writer) Start()

Indicates the start to accept the

func (*Writer) Stop

func (w *Writer) Stop()

Used to signal writer to stop processing items and exit.

func (*Writer) Submit

func (w *Writer) Submit(items ...interface{})

Submit pushes the items to the income buffer and they are placed onto the actual buffer from there.

type WriterConfig

type WriterConfig struct {
	BatchSize  int
	MaxRetries int
	Interval   time.Duration
	Timeout    time.Duration
}

Jump to

Keyboard shortcuts

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