executors

package
v1.10.52 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 9 Imported by: 7

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