Skip to content

Releases: pardnchiu/go-queue

v1.1.3

01 Jan 13:31

Choose a tag to compare

REFACTOR

  • Replace Queue.closed bool + sync.RWMutex with atomic.Uint32 state
  • Use CAS in Start() to ensure transition from stateCreated to stateRunning only
  • Use CAS loop in Shutdown() for idempotent closure (allow multiple calls)

UPDATE

  • Change Start() return type to error for state check error reporting
  • Change Config.Timeout type from int64 to time.Duration
  • Change default Timeout from 30 to 30 * time.Second

FIX

  • Fix Enqueue() error message formatting, use %w to wrap underlying error
  • Fix Shutdown() to call cancel() after completion for context cleanup

REFACTOR

  • Queue.closed bool + sync.RWMutex 替換為 atomic.Uint32 state
  • Start() 中使用 CAS 確保只能從 stateCreated 轉換到 stateRunning
  • Shutdown() 中使用 CAS loop 確保冪等性關閉(允許多次調用)

UPDATE

  • 修改 Start() 返回型別為 error,支援狀態檢查錯誤回報
  • Config.Timeout 型別從 int64 改為 time.Duration
  • 預設 Timeout 值從 30 改為 30 * time.Second

FIX

  • 修正 Enqueue() 錯誤訊息格式化,使用 %w 包裹底層錯誤
  • 修正 Shutdown() 在完成後呼叫 cancel() 清理 context

v1.1.2

01 Jan 05:55

Choose a tag to compare

REFACTOR

  • task.go: Refactored taskHeap from a slice type to a struct, added tasks and minCap fields to support dynamic minimum capacity.
  • task.go: Updated Len, Less, Swap, Push, and Pop methods of taskHeap to fit the new struct structure.
  • pending.go: Fixed newPending initialization to calculate dynamic minimum capacity based on workers and size (max(16, min(size/8, size/workers))).

PERF

  • task.go: Optimized heap shrink logic, changed trigger condition from capacity > taskHeapMinCap && length < capacity/4 to capacity > minCap*4 && length < capacity/taskHeapMinCapRatio.
  • task.go: Improved shrink capacity calculation, using max(capacity/4, minCap) to ensure it does not fall below the minimum capacity.
  • pending.go: Optimized promoteLocked access efficiency by retrieving the tasks field first to avoid repeated access.

UPDATE

  • new.go: Fixed newPending call, added workers parameter.

FIX

  • new.go: Added debug log for timeout trigger (task.timeout_triggered), recording id, preset, and timeout information.

REFACTOR

  • task.go: 將 taskHeap 從 slice 型別重構為 struct,新增 tasksminCap 欄位,支援動態最小容量
  • task.go: 調整 taskHeapLenLessSwapPushPop 方法,適配新的 struct 結構
  • pending.go: 修正 newPending 初始化,根據 workerssize 計算動態最小容量(max(16, min(size/8, size/workers))

PERF

  • task.go: 優化 heap shrink 邏輯,將觸發條件由 capacity > taskHeapMinCap && length < capacity/4 改為 capacity > minCap*4 && length < capacity/taskHeapMinCapRatio
  • task.go: 改進縮減容量計算,使用 max(capacity/4, minCap) 確保不低於最小容量
  • pending.go: 優化 promoteLocked 存取效率,先取得 tasks 欄位避免重複存取

UPDATE

  • new.go: 修正 newPending 呼叫,新增 workers 參數

FIX

  • new.go: 新增 timeout 觸發時的 debug 日誌(task.timeout_triggered),記錄 id、preset、timeout 資訊

v1.1.1

30 Dec 18:47

Choose a tag to compare

REFACTOR

  • Changed PresetConfig.Priority from string to Priority type
  • Changed WithRetry parameter from *int to variadic ...int, supports invocation without arguments

UPDATE

  • Improved timeout calculation logic, now directly uses time.Duration operations
  • Updated priority upgrade logic to use new priority constants instead of strings

PERF

  • Added taskHeap capacity reduction mechanism: when usage drops below 1/4 of capacity, automatically shrinks to half (minimum retained is 16)

REMOVE

  • Removed getPresetPriority function
  • Set old[n-1] = nil in Pop() to avoid memory leaks

REFACTOR

  • PresetConfig.Prioritystring 改為 Priority 型別,移除字串解析邏輯
  • WithRetry 參數從 *int 改為變長參數 ...int,支援無參數調用

UPDATE

  • 改進 timeout 計算邏輯,直接使用 time.Duration 運算
  • 更新優先級升級邏輯,使用新的優先級常數替代字串

PERF

  • 新增 taskHeap cap 縮減機制,當使用量低於容量 1/4 時自動縮減至一半(最小保留 16)

REMOVE

  • 移除 getPresetPriority 函式
  • Pop() 中設置 old[n-1] = nil 避免記憶體洩漏

v1.1.0

23 Dec 14:37

Choose a tag to compare

Features

  • Add Retry priority level (between High and Normal)
  • Add error retry mechanism with WithRetry() option
    // Enable retry with default max (3 times)
    q.Enqueue(ctx, "", action, queue.WithRetry(nil))
    
    // Enable retry with custom max
    maxRetry := 5
    q.Enqueue(ctx, "", action, queue.WithRetry(&maxRetry))
    
    // Updated callback (success only)
    q.Enqueue(ctx, "", action, queue.WithCallback(func(id string) {
      log.Printf("Task %s completed", id)
    }))

v1.0.0

23 Dec 03:38

Choose a tag to compare

feat: update README, add test workflow