-
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
Setting extensions on a outgoing client is not visible inside interceptors / tower service wrappers #770
Comments
Seems like a bug to me. #[doc(hidden)]
pub fn map<F, U>(self, f: F) -> Request<U>
where
F: FnOnce(T) -> U,
{
let message = f(self.message);
Request {
metadata: self.metadata,
message,
extensions: self.extensions,
}
} |
That's what it seems to be me. Happy to open a PR with mtoader@1427c5c if people agree that this is the right solution. |
That would be great! |
Opened #771. |
@davidpdrsn are you able to take a look at #771 ? |
Yes I'll take a look some time this week. |
Great, Thank you! |
davidpdrsn
pushed a commit
that referenced
this issue
Sep 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Version
➜ cargo tree | grep tonic
│ └── tonic v0.5.2
│ └── tonic-build v0.5.1
│ └── tonic v0.5.2 ()
├── tonic v0.5.2 ()
Platform
Darwin xxxxx.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
Crates
this is either
tonic
itself ortonic-build
depending on where we want to put the fix.Description
I have a generated gRPC client from a set of protobufs, and I am trying to do a generic metric / logger wrappers. I ended up using a tower wrapped target service to build the client. However in order to properly define the per request metrics I have to link a
metricsclient like
abstraction (preconfigured properly) to each request. What I did was to doreq.extensions_mut().insert(ctx.metrics.clone());
on atonic::Request<T>
that I get from using alet mut req = req.into_request();
after I build my generated req type.The expectation was that I would be able to access that on the hyper request that is being passed on the service abstraction itself. However, this is not happening.
Looking into the code I see that in the generated GrpcClient this happens in the
execute
method for a service endpoint:the
request.into_request()
here has the extensions set properly, however theserver_streaming
method does this:and the
request.map()
method does this:basically dropping the extensions on the floor.
My questions:
The text was updated successfully, but these errors were encountered: