Skip to content
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

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

oetyng
Copy link
Contributor

@oetyng oetyng commented Sep 13, 2021

  • This allows caller to apply a per-msg retry policy.
    BREAKING CHANGE: Removal of a public field plus Eq and PartialEq derivations on Config.

@oetyng oetyng requested a review from a team as a code owner September 13, 2021 16:49
@oetyng oetyng enabled auto-merge (rebase) September 13, 2021 16:50
Copy link
Member

@grumbach grumbach left a 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 forDefault::default Trait?
  • All the calls to send_message use None is the last arg really necessary?

src/config.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
@oetyng oetyng force-pushed the optional-per-msg-retry-policy branch from 6095390 to f7117bb Compare September 13, 2021 18:43
Copy link
Contributor

@joshuef joshuef left a 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.
@oetyng oetyng force-pushed the optional-per-msg-retry-policy branch from f7117bb to 3069b7f Compare September 14, 2021 09:28
joshuef
joshuef previously approved these changes Sep 14, 2021
Copy link
Contributor

@connec connec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small API suggestion.

src/config.rs Outdated Show resolved Hide resolved
@oetyng oetyng force-pushed the optional-per-msg-retry-policy branch from 3069b7f to a77c7e9 Compare September 14, 2021 09:58
@oetyng oetyng enabled auto-merge (rebase) September 14, 2021 09:58
@oetyng oetyng force-pushed the optional-per-msg-retry-policy branch 4 times, most recently from 061d964 to 9db914b Compare September 14, 2021 10:43
- Also removes structop.
@oetyng oetyng force-pushed the optional-per-msg-retry-policy branch from 9db914b to 04a47a4 Compare September 14, 2021 10:45
///
/// 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,
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@oetyng oetyng merged commit edc5493 into maidsafe:master Sep 14, 2021
@oetyng oetyng deleted the optional-per-msg-retry-policy branch September 14, 2021 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants