timedexecutor

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CancelPendingTasks defines a shutdown flag that causes all pending tasks to be canceled.
	CancelPendingTasks = timedqueue.CancelPendingElements

	// IgnorePendingTimeouts defines a shutdown flag, that makes the queue ignore the timeouts of the remaining queued
	// elements. Consecutive calls to Poll will immediately return these elements.
	IgnorePendingTimeouts = timedqueue.IgnorePendingTimeouts

	// DontWaitForShutdown causes the TimedExecutor to not wait for all tasks to be executed before returning from the
	// Shutdown method.
	DontWaitForShutdown timedqueue.ShutdownFlag = 1 << 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(t *TimedExecutor)

Option is the type for functional options of the TimedExecutor.

func WithMaxQueueSize

func WithMaxQueueSize(maxSize int) Option

WithMaxQueueSize is an Option for the TimedExecutor that allows to specify a maxSize of the underlying queue.

type ScheduledTask

type ScheduledTask = timedqueue.QueueElement

ScheduledTask is

type ShutdownFlag

type ShutdownFlag = timedqueue.ShutdownFlag

ShutdownFlag defines the type of the optional shutdown flags.

type TimedExecutor

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

TimedExecutor defines a scheduler that executes tasks in the background at a given time. It does not spawn any additional goroutines for each task and executes the tasks sequentially (in each worker).

func New

func New(workerCount int, opts ...Option) (timedExecutor *TimedExecutor)

New is the constructor for a TimedExecutor that creates a scheduler with a given number of workers that execute the scheduled tasks in parallel (whenever they become due).

func (*TimedExecutor) ExecuteAfter

func (t *TimedExecutor) ExecuteAfter(f func(), delay time.Duration) *ScheduledTask

ExecuteAfter executes the given function after the given delay.

func (*TimedExecutor) ExecuteAt

func (t *TimedExecutor) ExecuteAt(f func(), time time.Time) *ScheduledTask

ExecuteAt executes the given function at the given time.

func (*TimedExecutor) Shutdown

func (t *TimedExecutor) Shutdown(optionalShutdownFlags ...timedqueue.ShutdownFlag)

Shutdown shuts down the TimedExecutor and waits until the executor has shutdown gracefully.

func (*TimedExecutor) Size

func (t *TimedExecutor) Size() int

Size returns the amount of jobs that are currently scheduled for execution.

func (*TimedExecutor) WorkerCount

func (t *TimedExecutor) WorkerCount() int

WorkerCount returns the amount of background workers that this executor uses.

Jump to

Keyboard shortcuts

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