v1.2.1

v1.1.0 Release Notes

Released


Features


Custom Dependency Timeout

  • Specify timeout via Wait{ID: taskID, Delay: duration}
  • Default timeout is 1 minute when not configured

Dependency Failure Handling Strategy

  • Added Stop and Skip handling modes
    • Stop: Halt entire dependency chain on failure (default)
    • Skip: Skip failed dependency and continue executing current task
  • Configure failure behavior via Wait{ID: taskID, State: Skip}

Examples

  1. // Failure handling strategy
  2. taskID, _ := scheduler.Add("@daily", func() error {
  3. return processData()
  4. }, "Data processing", []Wait{
  5. {ID: taskA, State: Skip}, // Skip if taskA fails, continue execution
  6. {ID: taskB, State: Stop}, // Stop if taskB fails (default)
  7. })
  8. // Custom timeout + failure strategy combination
  9. taskID, _ := scheduler.Add("@daily", func() error {
  10. return processData()
  11. }, "Data processing", []Wait{
  12. {ID: taskA, Delay: 30 * time.Second, State: Skip}, // Wait 30s, skip on failure
  13. {ID: taskB, Delay: 10 * time.Second, State: Stop}, // Wait 10s, stop on failure
  14. })
  15. // Legacy version (deprecated in v2.*.*)
  16. taskID, _ := scheduler.Add("@daily", func() error {
  17. return processData()
  18. }, "Data processing", []int64{taskA, taskB})

Refactor


Compatibility Guarantee

  • Legacy code runs without modification
  • Maintains []int64 dependency support (deprecated in v2.*.*)
  • WaitState zero value is Stop, ensuring default behavior unchanged

Deprecation Notice


Features Removed in v2.*.*

  • []int64 format: Migrate to []Wait format for full feature support
    1. // Old format
    2. []int64{taskA, taskB}
    3. // New format
    4. []Wait{{ID: taskA}, {ID: taskB}}



新增


自定義依賴超時時間

  • 透過 Wait{ID: taskID, Delay: duration} 指定超時時間
  • 未設定時預設超時為 1 分鐘

依賴失敗處理策略

  • 新增 Stop 和 Skip 兩種處理方式
    • Stop: 依賴失敗時停止整個依賴鏈(預設)
    • Skip: 依賴失敗時跳過失敗的依賴,繼續執行當前任務
  • 透過 Wait{ID: taskID, State: Skip} 設定失敗行為

範例

  1. // 失敗處理策略
  2. taskID, _ := scheduler.Add("@daily", func() error {
  3. return processData()
  4. }, "Data processing", []Wait{
  5. {ID: taskA, State: Skip}, // taskA 失敗時跳過,繼續執行
  6. {ID: taskB, State: Stop}, // taskB 失敗時停止(預設)
  7. })
  8. // 自定義超時 + 失敗策略組合
  9. taskID, _ := scheduler.Add("@daily", func() error {
  10. return processData()
  11. }, "Data processing", []Wait{
  12. {ID: taskA, Delay: 30 * time.Second, State: Skip}, // 等待 30 秒,失敗時跳過
  13. {ID: taskB, Delay: 10 * time.Second, State: Stop}, // 等待 10 秒,失敗時停止
  14. })
  15. // 舊版本(將在 v2.*.* 廢棄)
  16. taskID, _ := scheduler.Add("@daily", func() error {
  17. return processData()
  18. }, "Data processing", []int64{taskA, taskB})

重構


相容性保證

  • 舊版本代碼無需修改即可正常運行
  • 保留 []int64 依賴支援(將在 v2.*.* 廢棄)
  • WaitState 零值為 Stop,確保預設行為不變

棄用預告


將在 v2.*.* 移除的功能

  • []int64 格式:建議遷移至 []Wait 格式以獲得完整功能支援
    1. // 舊格式
    2. []int64{taskA, taskB}
    3. // 新格式
    4. []Wait{{ID: taskA}, {ID: taskB}}