Comments (4)
Thanks for opening this detailed issue! So I am really cautious about introducing something like a PeerAddr
to request since it's designed intentionally to not expose any details about the transport/encodings.
For the client, I believe the channel can expose who it's connected too but this also might not make sense if you're load balancing.
For the server, hyper
itself provides a way to get nonexclusive access to the IO type which then can provide the remote address. Via this, we could probably provide some middleware to extract this and attach it to the metadata of every inbound request. What do you think about that? This would require that we somehow serialize the peer address into some form of bytes but I think this might provide the most flexible solution.
from tonic.
Hi @LucioFranco
I actually took a peek at using an interceptor to populate the metadata exactly as you suggest, but currently it has the http layer Request only so went looking elsewhere - I think it would be a good way of opting into the functionality (it's safe to say it's not needed by everyone) and feels quite natural.
I must admit I have only been considering the server side of this until now - I've not used the client yet, so can't really suggest anything meaningful.
Dom
from tonic.
Right so this gets a bit funky ill try to explain a bit here:
So in tower, we use two types of Service
's for servers. We use an outter MakeService
that creates some inner service for each connection, that inner service then gets dispatched aka called for each inbound request. The outter MakeService
contains a target. You can see some of this here https://github.com/hyperium/tonic/blob/master/tonic/src/transport/server.rs#L384 and you will notice that the type T
is actually ignored here. In fact this with hyper turns out to be the IO type given by a &
reference. So this is a bit lower level then what I'd like do to with interceptors but this is totally possible. So if you wrap your generated MakeService
from codegen like I do here you can extract and then inject. Let me know if that makes sense :)
from tonic.
Great - makes perfect sense.
I'll take a look some time in the next week, thanks for the pointers!
from tonic.
Related Issues (20)
- Current "uds" example does not compile HOT 3
- Release 0.12.0 HOT 6
- `tonic::transport::Channel` struct is not as safe to clone for parallel use HOT 2
- Error when building excamples
- how to manually fail a client streaming?
- Add debug spans for codec tracing
- test codec::prost::tests::encode_too_big panicks on 32-bit architectures
- Inserting metadata in a test panics with index out of bounds HOT 2
- Tonic 0.12.0 compiles tokio even when no features are enabled HOT 4
- Upgrading to tonic-reflection 0.12 breaks reflection HOT 2
- use of undeclared crate or module `tonic_reflection` HOT 2
- How does tonic library dynamically set up custom middleware HOT 1
- Naming collisions with std::marker::Sync/Send
- How to make tonic support tls HOT 3
- nit: inconsistent use of crate::Error vs Error in single transport src file
- calling grpc server hosted on cloud run with https fails with transport error HOT 2
- version 0.12.1 causes ClientTlsConfig to explode with invalid CryptoProvider HOT 1
- Configuring Timeout for Graceful Shutdown HOT 1
- How to get grpc-status in Layer?
- Make the TimeoutExpired a public tonic type rather than a transport type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tonic.