executors

package
v1.10.35 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkExecutor

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

func NewBulkExecutor

func NewBulkExecutor(execute Execute, opts ...BulkOption) *BulkExecutor

func (*BulkExecutor) Add

func (be *BulkExecutor) Add(task interface{}) error

func (*BulkExecutor) Flush

func (be *BulkExecutor) Flush()

func (*BulkExecutor) Wait

func (be *BulkExecutor) Wait()

type BulkOption

type BulkOption func(options *bulkOptions)

func WithBulkInterval

func WithBulkInterval(duration time.Duration) BulkOption

func WithBulkTasks

func WithBulkTasks(tasks int) BulkOption

type ChunkExecutor

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

func NewChunkExecutor

func NewChunkExecutor(execute Execute, opts ...ChunkOption) *ChunkExecutor

func (*ChunkExecutor) Add

func (ce *ChunkExecutor) Add(task interface{}, size int) error

func (*ChunkExecutor) Flush

func (ce *ChunkExecutor) Flush()

func (*ChunkExecutor) Wait

func (ce *ChunkExecutor) Wait()

type ChunkOption

type ChunkOption func(options *chunkOptions)

func WithChunkBytes

func WithChunkBytes(size int) ChunkOption

func WithFlushInterval

func WithFlushInterval(duration time.Duration) ChunkOption

type DelayExecutor

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

func NewDelayExecutor

func NewDelayExecutor(fn func(), delay time.Duration) *DelayExecutor

func (*DelayExecutor) Trigger

func (de *DelayExecutor) Trigger()

type Execute

type Execute func(tasks []interface{})

type LessExecutor

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

func NewLessExecutor

func NewLessExecutor(threshold time.Duration) *LessExecutor

func (*LessExecutor) DoOrDiscard

func (le *LessExecutor) DoOrDiscard(execute func()) bool

type PeriodicalExecutor

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

func NewPeriodicalExecutor

func NewPeriodicalExecutor(interval time.Duration, container TaskContainer) *PeriodicalExecutor

func (*PeriodicalExecutor) Add

func (pe *PeriodicalExecutor) Add(task interface{})

func (*PeriodicalExecutor) Flush

func (pe *PeriodicalExecutor) Flush() bool

func (*PeriodicalExecutor) Sync

func (pe *PeriodicalExecutor) Sync(fn func())

func (*PeriodicalExecutor) Wait

func (pe *PeriodicalExecutor) Wait()

type TaskContainer

type TaskContainer interface {
	// AddTask adds the task into the container.
	// Returns true if the container needs to be flushed after the addition.
	AddTask(task interface{}) bool
	// Execute handles the collected tasks by the container when flushing.
	Execute(tasks interface{})
	// RemoveAll removes the contained tasks, and return them.
	RemoveAll() interface{}
}

A type that satisfies executors.TaskContainer can be used as the underlying container that used to do periodical executions.

Jump to

Keyboard shortcuts

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