Help us shape the future of Go! Take the 2026 Go Developer Survey

btrunner

package module
v0.0.0-...-cbdc2d2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: MIT Imports: 5 Imported by: 0

README

btrunner

A task scheduler to batch same tasks.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorAlreadyEnqueued = errors.New("task is already enqueued")

ErrorAlreadyEnqueued is returned by the EnqueueTask method if the task has already been enqueued.

View Source
var ErrorDisposed = errors.New("task runner has been disposed")

ErrorDisposed means that BatchingTaskRunner is already disposed.

Functions

This section is empty.

Types

type BatchingTaskRunner

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

BatchingTaskRunner implements a task scheduler to batch multiple same tasks

func New

func New(concurrency int) *BatchingTaskRunner

New creates a new BatchingTaskRunner.

func (*BatchingTaskRunner) Dispose

func (b *BatchingTaskRunner) Dispose()

Dispose implements graceful disposal. If there are some queued task, they are canceled, and their callback function will called with ErrorDisposed error.

func (*BatchingTaskRunner) EnqueueTask

func (b *BatchingTaskRunner) EnqueueTask(name string, callback func(err error)) error

EnqueueTask schedules the task execution. If the return value is not nil, the callback is never called.

func (*BatchingTaskRunner) RegisterTask

func (b *BatchingTaskRunner) RegisterTask(name string, coolDown time.Duration, impl func(ctx context.Context) error)

RegisterTask registers a new task.

Directories

Path Synopsis
helper

Jump to

Keyboard shortcuts

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