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
andSkip
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
// Failure handling strategy
taskID, _ := scheduler.Add("@daily", func() error {
return processData()
}, "Data processing", []Wait{
{ID: taskA, State: Skip}, // Skip if taskA fails, continue execution
{ID: taskB, State: Stop}, // Stop if taskB fails (default)
})
// Custom timeout + failure strategy combination
taskID, _ := scheduler.Add("@daily", func() error {
return processData()
}, "Data processing", []Wait{
{ID: taskA, Delay: 30 * time.Second, State: Skip}, // Wait 30s, skip on failure
{ID: taskB, Delay: 10 * time.Second, State: Stop}, // Wait 10s, stop on failure
})
// Legacy version (deprecated in v2.*.*)
taskID, _ := scheduler.Add("@daily", func() error {
return processData()
}, "Data processing", []int64{taskA, taskB})
Refactor
Compatibility Guarantee
- Legacy code runs without modification
- Maintains
[]int64
dependency support (deprecated inv2.*.*
) -
WaitState
zero value isStop
, ensuring default behavior unchanged
Deprecation Notice
Features Removed in v2.*.*
-
[]int64
format: Migrate to[]Wait
format for full feature support
// Old format
[]int64{taskA, taskB}
// New format
[]Wait{{ID: taskA}, {ID: taskB}}
©️ 2025 邱敬幃 Pardn Chiu
Top comments (0)