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

fix: Only connect lazily (remove option to connect eagerly) #49

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

vrongmeal
Copy link
Member

Resolves: #43

Resolves: #43

Signed-off-by: Vaibhav Rabber <[email protected]>
@vrongmeal vrongmeal requested a review from a team as a code owner November 8, 2024 09:24
src/client.rs Outdated
@@ -561,7 +570,7 @@ impl ClientInner {
)?
.connect_timeout(config.connection_timeout)
.timeout(config.request_timeout);
let channel = if config.connect_lazily || force_lazy_connection {
let channel = if config.connection_mode == ConnectionMode::Lazy || force_lazy_connection {
Copy link
Member

Choose a reason for hiding this comment

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

Do you see a way to avoid the bool for force_lazy_connection?

Copy link
Member

@shikhar shikhar left a comment

Choose a reason for hiding this comment

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

please also revisit the internal bools around this

@shikhar
Copy link
Member

shikhar commented Nov 8, 2024

I think I'd prefer if we just went with lazy, always.

tonic::Channel will internally attempt to reconnect, so the possibility exists already of a connection error happening at request time.

Separately, let's consider ways in which we can clearly distinguish requests that were never transmitted due to failing at the connection stage, since those can be safely retried even if non-idempotent.

@vrongmeal vrongmeal changed the title feat: Add ConnectionMode enum fix: Only connect lazily (remove option to connect eagerly) Nov 12, 2024
@vrongmeal
Copy link
Member Author

Separately, let's consider ways in which we can clearly distinguish requests that were never transmitted due to failing at the connection stage, since those can be safely retried even if non-idempotent.

As a follow-up will take on looking at this.

@vrongmeal
Copy link
Member Author

@infiniteregrets something to note here in this PR, the connect methods have been made sync now since we're connecting lazily.

Moreover, maybe we should name them new instead of connect now?

Copy link
Member

@shikhar shikhar left a comment

Choose a reason for hiding this comment

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

yes, let's rename to new

Signed-off-by: Vaibhav Rabber <[email protected]>
@shikhar
Copy link
Member

shikhar commented Nov 13, 2024

Re: #54 - I guess those methods should be called new_with_connector?

@vrongmeal
Copy link
Member Author

WRT #54, ClientInner::connect_with_connector uses some different configurations for connecting with the endpoint, namely:

            .keep_alive_timeout(Duration::from_secs(5))
            .http2_keep_alive_interval(Duration::from_secs(5))

And it does not use a TLS config, which is used in the original connection:

            .tls_config(
                ClientTlsConfig::default()
                    .with_webpki_roots()
                    .assume_http2(true),
            )?

Are these supposed to be different? I was thinking of combining the functions. Maybe we have a flag for TLS configuration and if required, configs for keep alive timeouts as well?

@shikhar
Copy link
Member

shikhar commented Nov 13, 2024

The connector feature is intended for only internal consumption for now (from turmoil DST).

The key difference is we are using http as the scheme - I guess we could put that on ClientConfig? It may be useful when we have an emulator. Setting .tls_config() should be fine in this case too as it is only exercised for https.

Re: keep_alive_timeout(Duration::from_secs(5)) & http2_keep_alive_interval(Duration::from_secs(5)), I think that must have crept in inadvertently. Let's remove for now till we can properly consider what default knobs are appropriate for http2 & tcp keepalive from a client to s2 endpoint.

@infiniteregrets
Copy link
Member

keep_alive_timeout(Duration::from_secs(5)) & http2_keep_alive_interval(Duration::from_secs(5))

I think I copied that directly from the endpoint config from the DST

@vrongmeal
Copy link
Member Author

@infiniteregrets can you try this branch out once for your DST stuff?

The connector stuff is still gated behind the feature but I have made the dependencies non-optional since they are already hard dependencies on tonic (at least for us). This makes the code a bit cleaner.

src/client.rs Outdated
Comment on lines 655 to 657
#[cfg(feature = "connector")]
#[error("Invalid basin zone: should be None when connecting with connector")]
InvalidBasinZoneConnector,
Copy link
Member

Choose a reason for hiding this comment

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

I think better to panic in this case

Copy link
Member

@shikhar shikhar left a comment

Choose a reason for hiding this comment

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

LG aside from avoiding a new error variant, any integration issue for the connector feature can be a followup

Signed-off-by: Vaibhav Rabber <[email protected]>
@vrongmeal vrongmeal merged commit 94e6950 into main Nov 14, 2024
2 checks passed
@vrongmeal vrongmeal deleted the vrongmeal/eager-lazy branch November 14, 2024 14:32
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.

Ditch bools around lazy connection in favour of an enum
3 participants