workers

package
v4.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHeartbeatTimeout is returned from the worker when the task heartbeat is too slow,
	// tasks must heartbeat every 15s or else the worker abandons he task. The task is
	// not marked as a failure, but can be restarted by another worker.
	ErrHeartbeatTimeout = fmt.Errorf("task timeout")
)
View Source
var (
	// ErrScheduleQueueIsEmpty occurs when there is no schedule with
	// the `next_execution_time` in the past
	ErrScheduleQueueIsEmpty = errors.New("nothing to schedule")
)

Functions

func NewScheduleWorker

func NewScheduleWorker(db *sql.DB, queue queue.Queuer, interval time.Duration) queue.Worker

NewScheduleWorker creates a new task scheduling worker

func NewTaskWorker deprecated

func NewTaskWorker(dequeuer queue.Dequeuer, handler queue.TaskHandler) queue.Worker

NewTaskWorker creates a new Task Worker instance, the worker will enforce a default heartbeat ttl of 15 seconds.

Deprecated: Use NewTaskWorkerWithOpts instead.

func NewTaskWorkerWithOpts added in v4.6.0

func NewTaskWorkerWithOpts(dequeuer queue.Dequeuer, handler queue.TaskHandler, opts Options) queue.Worker

NewTaskWorkerWithOpts creates a task Worker instance with the specified options.

Types

type Options added in v4.6.0

type Options struct {
	// HeartbeatPeriod is the time the worker is allowed to wait for a heartbeat before
	// failing the task. If a task does not send a heartbeat before this value, then the task is
	// marked as failed. We recommend using a value like Queue.HeartbeatTTL + 100 time.Millisecond
	// to give your task handlers a little bit of extra time and avoiding any kind of race condition
	// between the heartbeat and the worker cleanup actually failing it.
	HeartbeatPeriod time.Duration
}

Options controls how the worker behaves.

Jump to

Keyboard shortcuts

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