-
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
Make networking handshake timeout configurable #1796
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.
Nice! LGTM but you probably want to see 👍 from Till or Ahmed ;-)
/// | ||
/// Time a node waits for handshake message to be received before | ||
/// giving up | ||
pub handshake_timeout: 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.
Can we use humantime::Duration
instead and setup schemar's correctly for it? You can find an example in config/http.rs
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.
definitely!
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.
Looks pretty good, the comment about passing in NetworkingOptions
is optional, but the main blocker is the need to use humantime::Duration
in configuration types.
} | ||
|
||
impl ConnectionManager { | ||
/// Creates the connection manager. | ||
pub(super) fn new(metadata: Metadata) -> Self { | ||
pub(super) fn new(metadata: Metadata, handshake_timeout: Duration) -> Self { |
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.
It might be better to future-proof this as pass in NetworkingOptions since this is a long-living object anyway.
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.
Yeah, i was thinking of that i just didn't want to make clones of it everywhere. And was honestly considering using an Arc for it (maybe with a type alias to reduce clutter).
On the other hand, the value cloned is not big and hence this can be an unnecessary optimisation
what do you think ?
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.
ConnectionManager is a long living value that lives as long as the node, cloning is absolutely fine here.
Take the entire NetworkingOptions for future-proofing
let retry_policy = self.options.connect_retry_policy.clone(); | ||
let mut retry_policy = retry_policy.iter(); |
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.
Why do you need to clone here? I think if you capture max_attempts() here you wouldn't have a problem with the projection reference below.
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 definitely, my fault. for some reason in my head iter() consumed self
but it actually doesn't.
drop the close of the rety 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.
Thanks for making the handshake timeout configurable @muhamadazmy. The changes look good to me.
Fixes #1765