Timeout Derivation
Last updated
This page explains how go-queue computes each task's timeout from the base timeout, the preset's priority, and the 15–120 second clamp.
Calculation Steps
The timeout is fixed at
Enqueue time (core/priority.go:17); later promotion does not change it.- Base:
PresetConfig.Timeoutwhen> 0, otherwiseConfig.Timeout - Apply the multiplier for the preset's priority
- Clamp to 15–120 seconds
WithTimeout(d)replaces the result withdand skips the clamp; adof zero or less gives the task an already-expired ctx
Multipliers
| Priority | Multiplier | With Config.Timeout = 30s |
|---|---|---|
PriorityImmediate | ÷ 4 | 15s (7.5s raised to the floor) |
PriorityHigh | ÷ 2 | 15s |
PriorityRetry | ÷ 2 | 15s |
PriorityNormal | × 1 | 30s |
PriorityLow | × 2 | 60s |
The multiplier comes from the preset's priority at
Enqueue. A retried task keeps its original timeout even though it re-enters at PriorityRetry.When a task exceeds its timeout, see Execution and Retries for what happens to the task and its goroutine.