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 (*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.
Click to show internal directories.
Click to hide internal directories.