v1.1.3

pardnchiu/go-queue

Last updated

NoteThis README was generated by SKILL, get the ZH version from here.



PRIORITY TASKS THAT NEVER STARVE!


Go ReferenceReleaseLicenseCoverage




A Go priority task queue with a bounded worker pool, anti-starvation promotion, and retries with per-task timeouts

Table of Contents



Features


go get github.com/pardnchiu/go-queue · Documentation

  • Five-Level Priority Heap — Immediate, High, Retry, Normal, and Low share one min-heap, with FIFO ordering inside each level.
  • Anti-Starvation Promotion — Low and Normal tasks promote automatically after a wait threshold, so bursts of high-priority work never starve them.
  • Preset-Driven Timeouts — Named presets bind a priority and a base timeout, and the effective timeout scales by priority within a 15–120 second window.
  • Retry and Panic Isolation — Failed tasks re-enter at a dedicated Retry priority, and panics become errors instead of killing the worker pool.
  • Atomic Lifecycle — CAS drives the Created → Running → Closed transitions, and Shutdown drains remaining tasks under a caller-supplied deadline.

Architecture


Full Architecture

graph TB
    C[Caller] -->|Enqueue| P[Pending Queue]
    P --> H[Priority Min-Heap]
    H -->|Pop + Promote| W[Worker Pool]
    W --> E[Execute + Timeout + Panic Recovery]
    E -->|Failed and retryable| P
    E -->|Success| CB[Callback]
    E --> L[slog Events]
    S[Atomic State] -.-> P
  1. graph TB
  2. C[Caller] -->|Enqueue| P[Pending Queue]
  3. P --> H[Priority Min-Heap]
  4. H -->|Pop + Promote| W[Worker Pool]
  5. W --> E[Execute + Timeout + Panic Recovery]
  6. E -->|Failed and retryable| P
  7. E -->|Success| CB[Callback]
  8. E --> L[slog Events]
  9. S[Atomic State] -.-> P

License


This project is licensed under the MIT LICENSE.

Author


Just open an issue to share an idea.
go-queue contributors


©️ 2025 邱敬幃 Pardn Chiu
中文