forked from robfig/cron
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
apiAPI design changesAPI design changesenhancementNew feature or requestNew feature or requestv1.1Deferred to v1.1 releaseDeferred to v1.1 release
Description
Summary
Currently only TimeoutWithContext wrapper supports context propagation. Other wrappers could benefit from context awareness for better integration with modern Go patterns.
Current Context Support
| Wrapper | Context Support | Notes |
|---|---|---|
| TimeoutWithContext | ✅ Yes | Full context propagation |
| Timeout | ❌ No | Abandonment model |
| Recover | ❌ No | Could log context values |
| RetryWithBackoff | ❌ No | Could cancel on context done |
| CircuitBreaker | ❌ No | Could respect context |
| DelayIfStillRunning | ❌ No | Could timeout on context |
| SkipIfStillRunning | ❌ No | Could log context |
Suggested Enhancements
RetryWithBackoffContext
func RetryWithBackoffContext(logger Logger, maxRetries int, ...) JobWrapper {
return func(j Job) Job {
return &retryContextJob{...}
}
}
// Cancels retry loop when context is done
func (r *retryContextJob) RunWithContext(ctx context.Context) {
for attempt := 1; ...; attempt++ {
select {
case <-ctx.Done():
return // Stop retrying
default:
// Try execution
}
}
}CircuitBreakerContext
Could skip execution when context is already cancelled.
Benefits
- Better integration with HTTP server shutdown
- More responsive cancellation
- Consistent context propagation throughout chain
Files
chain.go- Wrapper implementationsretry.go- Retry and circuit breaker
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
apiAPI design changesAPI design changesenhancementNew feature or requestNew feature or requestv1.1Deferred to v1.1 releaseDeferred to v1.1 release