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

RSDK-6283 - parallel dial attempts #115

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

stuqdog
Copy link
Member

@stuqdog stuqdog commented May 24, 2024

No description provided.

@@ -459,7 +453,7 @@ impl<T: AuthMethod> DialBuilder<T> {
let mut uri_parts = uri.clone().into_parts();
uri_parts.scheme = Some(Scheme::HTTP);
let uri = Uri::from_parts(uri_parts)?;
Channel::builder(uri.clone()).connect().await?
Channel::builder(uri).connect().await?
Copy link
Member Author

Choose a reason for hiding this comment

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

(flyby) this was an unnecessary clone

Comment on lines +467 to +479
fn clone(&self) -> Self {
DialBuilder {
state: WithoutCredentials(()),
config: DialOptions {
credentials: None,
webrtc_options: self.config.webrtc_options.clone(),
uri: self.duplicate_uri(),
disable_mdns: self.config.disable_mdns,
allow_downgrade: self.config.allow_downgrade,
insecure: self.config.insecure,
},
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

the connect() method consumes a DialBuilder, so we need to be able to clone them in order to allow parallel attempts. Incidentally, this allows us to clean up a bit some of the dial logic below.

Comment on lines +576 to +578
let original_uri2 = duplicate_uri(&original_uri).ok_or(anyhow::anyhow!(
"Attempting to connect but there was no uri"
))?;
Copy link
Member Author

Choose a reason for hiding this comment

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

Slightly annoying that this is duplicative. original_uri2 will never fail (if it were to do so, original_uri would have failed before so we could unwrap() rather than the ok_or block, but I think adding unwraps is a bit uglier/less idiomatic than the minorly duplicative error handling here.

@stuqdog stuqdog marked this pull request as ready for review May 24, 2024 15:00
@stuqdog stuqdog requested a review from a team as a code owner May 24, 2024 15:00
Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

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

I read through it, but I would be lying if I said I understood most of it. Some nits, but I'll leave actual approval to those who understand what's going on 😅

src/rpc/dial.rs Outdated
"Attempting to connect but there was no uri"
))?;
// We want to short circuit and return the first `Ok` result from our connection
// attempts, whish `tokio::select!` does great. Buuuuut, we don't want to
Copy link
Member

Choose a reason for hiding this comment

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

nit - whish

src/rpc/dial.rs Outdated
// attempts, whish `tokio::select!` does great. Buuuuut, we don't want to
// abandon the `Err` results, and we want to provide comprehensive logging for
// debugging purposes. Hence the loop and pinning. The pinning lets us reference
// the same future multiple times, while the loop lets immediately return on the
Copy link
Member

Choose a reason for hiding this comment

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

nit - "while the loop immediately returns"

@stuqdog
Copy link
Member Author

stuqdog commented May 28, 2024

I read through it, but I would be lying if I said I understood most of it. Some nits, but I'll leave actual approval to those who understand what's going on 😅

Cool totally fair, thanks for looking it over! Let me know if you'd like to set aside a couple minutes to talk through the PR, I'd be happy to explain anything that's unclear :)

@stuqdog stuqdog merged commit fadd59d into viamrobotics:main Jun 3, 2024
4 checks passed
@stuqdog stuqdog deleted the make-parallel-dial-attempts branch June 3, 2024 13:23
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.

3 participants