-
Notifications
You must be signed in to change notification settings - Fork 44
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
[Refactoring] Consolidate multiple create Tonic channel functions #2469
[Refactoring] Consolidate multiple create Tonic channel functions #2469
Conversation
} | ||
|
||
fn keep_alive_interval(&self) -> Duration { | ||
Duration::from_secs(60) |
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.
Hard-coding this for the CLI should be okay; wanted to keep the trait as-is to avoid changing prod code.
@@ -63,7 +67,7 @@ pub(crate) struct ConfirmMode { | |||
} | |||
|
|||
#[derive(Args, Clone, Default)] | |||
pub(crate) struct NetworkOpts { | |||
pub struct NetworkOpts { |
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 now need to export this struct to make this work.
server/tests/trim_gap_handling.rs
Outdated
connect_timeout: 1000, | ||
request_timeout: 5000, |
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.
Seemed reasonable for tests.
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 creating this PR @pcholakov. This is a good clean up! The one question I have is whether we want to enable create_tonic_channel_from_advertised_address
to also accept a request timeout so that we don't have to change the semantics of restatectl
?
crates/cli-util/src/opts.rs
Outdated
fn keep_alive_timeout(&self) -> Duration { | ||
Duration::from_millis(self.request_timeout) | ||
} |
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.
Isn't this a different meaning than before? Before request_timeout
defined a timeout for the overall request.
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.
Thank you for pointing this out, I was very sloppy here! I totally mixed up request timeout and connect timeout. Fixed now by introducing a dedicated optional request_timeout()
method on the config trait.
I'm still defaulting keep-alive timeout to the connect_timeout
with a very large fixed interval for the CLI. Previously we didn't set it but I think this is benign because:
- a keep-alive should be cheap for the peer to process; we should receive a response much faster than a typical request as it requires effectively zero "service time"
- CLI connections are in any event unlikely to live longer than the (hard-coded to 60s) keep-alive interval
It feels kludgey but I didn't want to make these optional in the common config trait.
server/tests/trim_gap_handling.rs
Outdated
fn keep_alive_timeout(&self) -> Duration { | ||
Duration::from_millis(self.request_timeout) | ||
} |
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.
Same question here. Before we seem to have set Channel::builder().timeout(request_timeout)
which is no longer the case with this change.
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.
Fixed now; I was being blind - I've added a dedicated request_timeout
property. I messed up when merging the logic of the cli/test-only and production code endpoint building.
AdvertisedAddress::Http(uri) => { | ||
Channel::builder(uri) | ||
.connect_timeout(ctx.connect_timeout()) | ||
.timeout(ctx.request_timeout()) |
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.
How are we setting the overall timeout now? Or is this no longer needed?
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.
Added back! My mistake!
5200c2a
to
81d3b2e
Compare
3aca5aa
to
df3d0bd
Compare
crates/cli-util/src/opts.rs
Outdated
fn keep_alive_timeout(&self) -> Duration { | ||
Duration::from_millis(self.request_timeout) | ||
} |
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.
Thank you for pointing this out, I was very sloppy here! I totally mixed up request timeout and connect timeout. Fixed now by introducing a dedicated optional request_timeout()
method on the config trait.
I'm still defaulting keep-alive timeout to the connect_timeout
with a very large fixed interval for the CLI. Previously we didn't set it but I think this is benign because:
- a keep-alive should be cheap for the peer to process; we should receive a response much faster than a typical request as it requires effectively zero "service time"
- CLI connections are in any event unlikely to live longer than the (hard-coded to 60s) keep-alive interval
It feels kludgey but I didn't want to make these optional in the common config trait.
server/tests/trim_gap_handling.rs
Outdated
fn keep_alive_timeout(&self) -> Duration { | ||
Duration::from_millis(self.request_timeout) | ||
} |
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.
Fixed now; I was being blind - I've added a dedicated request_timeout
property. I messed up when merging the logic of the cli/test-only and production code endpoint building.
AdvertisedAddress::Http(uri) => { | ||
Channel::builder(uri) | ||
.connect_timeout(ctx.connect_timeout()) | ||
.timeout(ctx.request_timeout()) |
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.
Added back! My mistake!
@@ -30,36 +30,47 @@ use restate_types::net::{AdvertisedAddress, BindAddress}; | |||
|
|||
use crate::{cancellation_watcher, ShutdownError, TaskCenter, TaskKind}; | |||
|
|||
pub fn create_tonic_channel_from_advertised_address<T: CommonClientConnectionOptions>( | |||
pub fn create_tonic_channel<T: CommonClientConnectionOptions>( |
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.
An approach where we accept a closure to customize the endpoint might be a nicer alternative if CommonClientConnectionOptions
gets any more complex, but I'm punting on that for now.
81d3b2e
to
9592d6a
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.
Nice work @pcholakov. This is a good improvement and clean up :-) LGTM. +1 for merging.
df3d0bd
to
6ef9a2a
Compare
Eliminates some duplication across test and prod code for creating GRPC channels.