-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add ConstantBackoff: always return the same duration #12
base: main
Are you sure you want to change the base?
Conversation
This does not do exponential backoff, but rather retries with a constant time
policies/constant.go
Outdated
import "time" | ||
|
||
func GetConstantPolicy(duration time.Duration, max int) Policy { | ||
return GetExponentialPolicy(1, duration, max) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's really a constant, what would the max do? why not just write the constant policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just write the constant policy that backs off by duration time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to request changes, sorry.
You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab. |
a293070
to
d974ef1
Compare
Kudos, SonarCloud Quality Gate passed! |
t.Run("value is capped at max count", func(t *testing.T) { | ||
policy := policies.GetConstantPolicy(time.Millisecond * 100) | ||
assert.Equal(t, policy(10), policy(10)) | ||
assert.Equal(t, policy(10), policy(11)) | ||
assert.Equal(t, policy(10), policy(12)) | ||
assert.Equal(t, policy(10), policy(13)) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this test
Write ConstantBackoff which always returns the same duration, except for the first attempt which is always a zero
This change is