batcher

package
v0.0.0-...-4702bed Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSize     = 100
	DefaultBuffer   = 100
	DefaultWorker   = 5
	DefaultInterval = time.Second
)
View Source
var (
	ErrorNotSetFunction = errors.New("not set do function")
)

Functions

This section is empty.

Types

type Batcher

type Batcher struct {
	Do       func(ctx context.Context, val map[string][]interface{})
	Sharding func(key string) int
	// contains filtered or unexported fields
}

func NewBatcher

func NewBatcher(fn DoFuntion, opts ...Option) *Batcher

func (*Batcher) Add

func (b *Batcher) Add(key string, val interface{}) error

func (*Batcher) Close

func (b *Batcher) Close()

func (*Batcher) Start

func (b *Batcher) Start() error

type Config

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

type DoFuntion

type DoFuntion func(ctx context.Context, val map[string][]interface{})

type Option

type Option func(c *Config)

func WithBuffer

func WithBuffer(b int) Option

func WithInterval

func WithInterval(i time.Duration) Option

func WithSize

func WithSize(s int) Option

func WithWorker

func WithWorker(w int) Option

Jump to

Keyboard shortcuts

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