batch

package module
v0.0.0-...-76f2ba0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: MIT Imports: 4 Imported by: 0

README

go-batch

Batch goroutine helper

Documentation

Index

Constants

View Source
const (
	DefaultInterval = time.Second
	DefaultSize     = 1000
)

Variables

View Source
var (
	AlreadyRunningError = errors.New("Queue already running.")
)
View Source
var (
	NoDrainerError = errors.New("No Drainer in Queue")
)
View Source
var (
	NotRunningError = errors.New("Queue is not running")
)

Functions

This section is empty.

Types

type DrainFunc

type DrainFunc func(context.Context, []interface{}) error

func (DrainFunc) Drain

func (df DrainFunc) Drain(ctx context.Context, batch []interface{}) error

type Drainer

type Drainer interface {
	Drain(context.Context, []interface{}) error
}

type Queue

type Queue struct {
	Size     int
	Interval time.Duration
	Drainer  Drainer
	Retries  int
	// contains filtered or unexported fields
}

func (*Queue) Add

func (s *Queue) Add(x interface{}) error

func (*Queue) Flush

func (s *Queue) Flush(ctx context.Context, batch []interface{}) (err error)

func (*Queue) IsUp

func (s *Queue) IsUp() bool

func (*Queue) MustAdd

func (s *Queue) MustAdd(x interface{})

func (*Queue) MustRun

func (s *Queue) MustRun(ctx context.Context)

func (*Queue) Run

func (s *Queue) Run(ctx context.Context) error

func (*Queue) Stats

func (s *Queue) Stats() (total, flush_size, flush_tick, flush_err uint64)

Jump to

Keyboard shortcuts

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