-
Notifications
You must be signed in to change notification settings - Fork 66
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(retries): extend send msg api with retry cfg #325
Conversation
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.
Couple of (probably naive) questions
- Why not use the DEFAULT macros for
Default::default
Trait? - All the calls to
send_message
useNone
is the last arg really necessary?
6095390
to
f7117bb
Compare
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 need a BREAKING CHANGE:
commit w/ the Eq/PartialEq
being dropped
- Additional api added allowing caller to apply a per-msg retry policy. BREAKING CHANGE: Removal of Eq and PartialEq derivations on config.
f7117bb
to
3069b7f
Compare
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.
Small API suggestion.
3069b7f
to
a77c7e9
Compare
061d964
to
9db914b
Compare
- Also removes structop.
9db914b
to
04a47a4
Compare
/// | ||
/// Retrying continues until this time has elapsed. | ||
/// The number of retries before that happens, will be decided by the other retry config options. | ||
pub retrying_max_elapsed_time: Duration, |
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.
Another reason I ended up with the min_retry_duration
name is that the implementation uses it like a minimum:
match self.max_elapsed_time {
Some(v) if self.get_elapsed_time() > v => None,
_ => {
let random = rand::random::<f64>();
let randomized_interval = Self::get_random_value_from_interval(
self.randomization_factor,
random,
self.current_interval,
);
self.current_interval = self.increment_current_interval();
Some(randomized_interval)
}
}
E.g., retry until more than max_elapsed_time
has passed, so it's really the minimum amount of 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 think it could be argued that's a bug upstream.
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.
That's because it would be very bad to put
if self.get_elapsed_time() == v
..since you would then probably never hit that.
So, such cases always use >=
or >
, even though it's conceptually a max time that is modeled.
Max
elapsed time is more accurate because there is not going to be any more time spent retrying than that.
If the retried call succeeds though, it can be a lot shorter than that, so Min
is not very accurate.
I think they have it right there.
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 think the implementation is fine, it's just the name sets the wrong expectation for me. "Max elapsed time" makes me think it will not retry for longer than that, when in reality it will retry for at least that long, but in fact strictly longer.
BREAKING CHANGE: Removal of a public field plus
Eq
andPartialEq
derivations onConfig
.