-
Notifications
You must be signed in to change notification settings - Fork 19
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
Retry cleanups #318
base: master
Are you sure you want to change the base?
Retry cleanups #318
Conversation
Default to milliseconds internally. The behavior would be incorrect with any other time unit anyway: due to multiple unit.toMillis(unit.toMillis(unit.toMillis(x))) conversions. Extract duplicating code in unit test.
NakadiException.throwNonNull throws IllegalStateException while NakadiException is itself exception, also throwNonNull is a non null check that is retrofitted to throw unconditionally. This all is rather confusing.
|
||
long nextBackOffMillis(long nowMillis) { |
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.
Extracted for testing.
|
||
if (isFinished()) { | ||
return STOP; | ||
} | ||
|
||
workingInterval = unit.toMillis(workingInterval) * (workingAttempts * workingAttempts); | ||
workingInterval = workingInterval * (workingAttempts * workingAttempts); |
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.
This still looks like too aggressive increase. workingInterval = startingInterval * pow(workingInterval, 2)
would be OK (and easier to review).
exponentialRetry.nextBackOffMillis(100); | ||
assertFalse(exponentialRetry.isFinished()); | ||
exponentialRetry.nextBackOffMillis(101); | ||
assertFalse(exponentialRetry.isFinished()); |
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.
Would previously fail here as accumulated time was 202 milliseconds (instead of 101).
For context see #315