v1.1.3

Priority Levels

Last updated


This page explains the five priority levels, how ties break, and where a task's priority comes from.

Five Priority Levels


Every task lives in one min-heap. Lower values run first; ties break FIFO on startAt, the enqueue or re-enqueue time (core/task.go:36).
ConstantValuePurpose
PriorityImmediate0Runs first; also the zero value of Priority
PriorityHigh1High priority; where promoted Normal tasks end up
PriorityRetry2Reserved for retries, ahead of regular traffic
PriorityNormal3Regular tasks; where promoted Low tasks end up
PriorityLow4Background tasks

How a Task Gets Its Priority


A task's priority comes from the PresetConfig.Priority of the presetName passed to Enqueue (core/new.go:252); there is no per-task priority option. When the preset name is unknown (including "") or the preset leaves Priority unset, the task gets the zero value PriorityImmediate. For regular-priority work, define a preset and set PriorityNormal explicitly.
EventPriority Afterwards
EnqueueThe preset's Priority
Waited past the promotion thresholdOne level up, see Anti-Starvation Promotion
Failed with retries leftPriorityRetry, see Execution and Retries

Presets are defined in Presets.
中文