1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 00:02:28 +08:00

Add Retry backoff policy (#173)

The aim of this policy is to enable the configuration of various types of backoff mathematical curves. Should this modification be deemed suitable,
I will proceed to implement an exponential curve backoff policy and set of custom backoff policy
Warning: It's major break
This commit is contained in:
donutloop
2024-02-21 03:20:24 +01:00
committed by GitHub
parent cd156dba5f
commit cacbf97223
3 changed files with 49 additions and 20 deletions

View File

@@ -20,7 +20,7 @@ func ExampleContext() {
}
Retry(increaseNumber,
RetryDuration(time.Microsecond*50),
RetryWithLinearBackoff(time.Microsecond*50),
Context(ctx),
)
@@ -30,7 +30,7 @@ func ExampleContext() {
// 4
}
func ExampleRetryDuration() {
func ExampleRetryWithLinearBackoff() {
number := 0
increaseNumber := func() error {
number++
@@ -40,7 +40,7 @@ func ExampleRetryDuration() {
return errors.New("error occurs")
}
err := Retry(increaseNumber, RetryDuration(time.Microsecond*50))
err := Retry(increaseNumber, RetryWithLinearBackoff(time.Microsecond*50))
if err != nil {
return
}
@@ -81,7 +81,7 @@ func ExampleRetry() {
return errors.New("error occurs")
}
err := Retry(increaseNumber, RetryDuration(time.Microsecond*50))
err := Retry(increaseNumber, RetryWithLinearBackoff(time.Microsecond*50))
if err != nil {
return
}