batch

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batcher

type Batcher[IN, OUT any] struct {
	utils.SpinLock
	// contains filtered or unexported fields
}

func NewBatcher

func NewBatcher[IN, OUT any](f Func[IN, OUT], tagID string, opt ...Option) *Batcher[IN, OUT]

func (*Batcher[IN, OUT]) Enter added in v0.11.25

func (f *Batcher[IN, OUT]) Enter(entry Entry[IN, OUT])

func (*Batcher[IN, OUT]) EnterAndWait added in v0.11.25

func (f *Batcher[IN, OUT]) EnterAndWait(entry Entry[IN, OUT])

type Entry

type Entry[IN, OUT any] interface {
	Value() IN
	Callback(out OUT)
	// contains filtered or unexported methods
}

func NewEntry

func NewEntry[IN, OUT any](v IN, callbackFn func(out OUT)) Entry[IN, OUT]

type Func

type Func[IN, OUT any] func(targetID string, entries []Entry[IN, OUT])

type MultiBatcher

type MultiBatcher[IN, OUT any] struct {
	// contains filtered or unexported fields
}

func NewMulti

func NewMulti[IN, OUT any](f Func[IN, OUT], opt ...Option) *MultiBatcher[IN, OUT]

NewMulti creates a pool of Batcher functions. By calling Enter or EnterAndWait you add the item into the Batcher which is identified by 'tagID'.

func (*MultiBatcher[IN, OUT]) Enter

func (fp *MultiBatcher[IN, OUT]) Enter(targetID string, entry Entry[IN, OUT])

func (*MultiBatcher[IN, OUT]) EnterAndWait

func (fp *MultiBatcher[IN, OUT]) EnterAndWait(targetID string, entry Entry[IN, OUT])

type NA

type NA = struct{}

type Option

type Option func(*config)

func WithBatchSize

func WithBatchSize(batchSize int32) Option

WithBatchSize sets the maximum number of entries to batch together. Defaults to 100.

func WithMaxWorkers

func WithMaxWorkers(maxWorkers int32) Option

WithMaxWorkers sets the maximum number of workers to use. Defaults to runtime.NumCPU() * 10.

func WithMinWaitTime

func WithMinWaitTime(minWaitTime time.Duration) Option

WithMinWaitTime sets the minimum amount of time to wait before flushing a batch. Defaults to 0.

Jump to

Keyboard shortcuts

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