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

feat: Add Grpc::with_origin for clients #1017

Merged
merged 1 commit into from
Jun 20, 2022
Merged

Conversation

LucioFranco
Copy link
Member

No description provided.

Copy link

@kvc0 kvc0 left a comment

Choose a reason for hiding this comment

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

Thanks for this; I’m looking forward to using it soon!

.service(client);

let mut client = EchoClient::new(svc);
let mut client = EchoClient::with_origin(client, uri);
Copy link

Choose a reason for hiding this comment

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

This replaces most of the “this feels wrong” when migrating from Tonic 0.6 to 0.7 while using rustls. Much more ergonomic and friendly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok perfect, my 1.0 roadmap would change this to be the new fn since you can always provide an empty uri. This was exactly the same thought I had when I wrote that example so glad that this fixes most of that :)

@@ -296,6 +316,7 @@ impl<T: Clone> Clone for Grpc<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
origin: self.origin.clone(),
Copy link

Choose a reason for hiding this comment

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

While I cannot judge whether this clone or the ServiceBuilder’s clone would be more efficient, this tradeoff with the scheme and authority being owned by the Grpc seems right to optimize for the expected use cases, making it clear how to replace Channels going forward without needing to learn Tower as well just to get started.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I think the structure works as follows we clone the server which just contains the client then this struct constructs you origin + grpc path + body and submits that to the service.

@LucioFranco
Copy link
Member Author

@kvc0 thanks for the feedback!

@LucioFranco LucioFranco merged commit 10f6d2f into master Jun 20, 2022
@LucioFranco LucioFranco deleted the lucio/add-origin-codegen branch June 20, 2022 13:36
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.

2 participants