Priority-based queue with automatic timeout promotion
Published: (December 27, 2025 at 11:19 PM EST)
1 min read
Source: Dev.to
Source: Dev.to
Core Features
Bounded Concurrency
- Configurable worker pool size (default: CPU cores × 2).
- Tasks beyond worker capacity queue up to avoid system overload while maximizing hardware utilization.
Priority Queue and Promotion
- Five‑level priority system implemented with a min‑heap: Immediate > High > Retry > Normal > Low.
- Higher‑priority tasks execute first; tasks with the same priority are processed FIFO.
- Tasks that wait for a long time are automatically promoted to a higher priority to prevent starvation.
- Promotion thresholds are calculated based on configured timeouts.
Error Retry
- When a task fails, it can be automatically retried.
- Retry tasks are re‑enqueued with
Retrypriority, which sits betweenHighandNormal, providing a delayed retry effect.