Add custom backoff setter (#176)

Users should have the capability to customize the backoff pattern and accordingly adjust it within the retry mechanism.
This commit is contained in:
donutloop authored and GitHub committed 2024-02-23 10:04:38 +08:00
1 parent 2e1c2276a5
commit 860a499f98
3 files changed
+69

No files matched your search

+12
View File
@@ -44,6 +44,18 @@ func RetryTimes(n uint) Option {
}
}
// RetryWithCustomBackoff set abitary custom backoff strategy
// todo: Add playground link
func RetryWithCustomBackoff(backoffStrategy BackoffStrategy) Option {
if backoffStrategy == nil {
panic("programming error: backoffStrategy must be not nil")
}
return func(rc *RetryConfig) {
rc.backoffStrategy = backoffStrategy
}
}
// RetryWithLinearBackoff set linear strategy backoff
// todo: Add playground link
func RetryWithLinearBackoff(interval time.Duration) Option {