3 ms·
## Features ### Custom Dependency Timeout - Specify timeout via `Wait{ID: taskID, Delay: duration}` - Default timeout is 1 minute when not configured ### Depe
by pardnchiu 1y ago
## 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
```go
// 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 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
```go
// Old format
[]int64{taskA, taskB}
// New format
[]Wait{{ID: taskA}, {ID: taskB}}
```