-
Notifications
You must be signed in to change notification settings - Fork 1k
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
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.
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); |
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.
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.
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.
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(), |
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.
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.
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.
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.
@kvc0 thanks for the feedback! |
No description provided.