-
Notifications
You must be signed in to change notification settings - Fork 37
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
Configurable network error retry policy #1782
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.
Thanks for making the network error retry policy configurable @muhamadazmy :-) The changes look good to me. I had one suggestion for a slight simplification. +1 for merging after resolving the comment.
crates/types/src/config/common.rs
Outdated
/// # Network error retry policy | ||
/// | ||
/// The retry policy for node network error | ||
network_error_retry_policy: Option<RetryPolicy>, |
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.
Wondering whether we can define the type as RetryPolicy
because RetryPolicy
has a None
variant as well.
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.
@tillrohrmann
True, there is a None variant on the RetryPolicy. But i didn't want break compatibility with current configurations files which has no network_error_retry_policy defined. If we just use RetryPolicy it will default to None (hence no retry), which breaks the default behaviour which has exponential retry.
But with Option, if network_error_retry_policy is completely missing from the config the function network_error_retry_policy
can still return a default policy (the one that was hard coded in code), unless you configure retry policy explicitly to None in config (like network_error_retry_policy: none
) to explicitly disable retries
I am still totally fine of using RetryPolicy instead of Option if you think that is acceptable behaviour, just let me know :)
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.
Can we configure serde using the same default value as the one we define in the Default
implementation? Then if nothing is specified we would default to
RetryPolicy::exponential(
Duration::from_millis(10),
2.0,
Some(15),
Some(Duration::from_secs(5))
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 that the current Default
implementation should already be respected. No need to instruct serde
separately. The defaults for the configuration are configured here:
Line 167 in 3271b79
let mut figment = Figment::from(Serialized::defaults(defaults)) |
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.
Ah that's good to know. Good one :)
This way we don't have to set it explicitly in serde
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.
Nice work @muhamadazmy. LGTM. +1 for merging :-)
Fixes #1769
This makes the network error retry policy configurable for the node