batch

package
v0.0.0-...-36d8597 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package for work in batch mode

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	sync.Mutex

	Size     int           // Size is the max entries limit
	Interval time.Duration // Interval is the flush interval
	Worker   int
	Retries  int // Retries is count for try fault exec a command
	// contains filtered or unexported fields
}

Config

func New

func New(_ context.Context, cb func([]*Item) interface{}) (*Config, error)

TODO: add config for as timeout, retries, etc... New - create a new batch

func (*Config) Push

func (c *Config) Push(item interface{}) (chan interface{}, error)

func (*Config) Run

func (c *Config) Run(ctx context.Context)

run - starts a loop flushing at the Interval

type Item

type Item struct {
	CB   chan interface{}
	Item interface{}
}

Item

func NewItem

func NewItem(item interface{}) *Item

Jump to

Keyboard shortcuts

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