-
Notifications
You must be signed in to change notification settings - Fork 73
Figure out how to serve multiple services on the same socket address #2
Comments
I was wondering if it could be done by implementing some kind of Or did you have something more automatic in mind? |
I was wondering if it could be done with tuples and avoid a linear scan to find the service that matches. I haven't really thought through it in detail yet. |
Tuples ‒ well, I guess why not. It is probably more natural. Maybe a Linear scan looked simpler. But the trait could be extended to some kind of If that sounds in about the right direction, I could make a PR with a first shot (though I can't promise how soon). |
I would appreciate a PR to get things started! This is not on my short list of priorities. |
It seems likely that we could instrument tower-router (or something like it) to dispatch requests to the appropriate service base don the URI prefix |
The main issue w/ One way to deal w/ this is to box the services, but this requires some runtime overhead. Another way would be to use a static routing strategy... this is trickier. |
Has there been any new thinking here in the intervening 6 months? I'm looking to start using tower-grpc, and I could probably put something together if there's a direction in mind, but I'm not yet familiar enough with the general tower ecosystem to be designing solutions from scratch... |
Hey, I have been doing a lot of exploration into how I would like to see "app development" go in the context of tower. This has mostly been done in the context of I'm usually on http://gitter.im/tokio-rs/dev. |
Well, tower-web is public now 🙌 I’m gonna do some comparison and see what it would look like to borrow some of that logic and use it here. |
Per a lot of the discussion above:
I'm thinking we may be able to introduce a new
DISCLAIMER: I still need to experiment with this, and the Anyway, hopefully I will have time to experiment a bit with this. I am definitely interested in feedback on the pattern. Just let me know. Any and all feedback is welcome. |
@thedodd : your idea sounds good to me! Though I'm not a rust expert so take my opinion with a pinch of salt. Let me know if I can help with testing of an early prototype or perhaps help with coding in case you have your changes publicly available somewhere in a branch. thanks! |
We have been using a simple service router to run 2 services on a single endpoint for quite a long time already. It's rather simple but it is usable and IMHO worth sharing: https://github.com/jkryl/grpc-router . Have fun! |
@jkryl awesome! How likely do you think it would be to be able to factor such a pattern into upstream tower-grpc? |
@thedodd I believe this pattern actually belongs in something like the base tower repo, as you can abstract the recognizing part and be abstract over services. Though we are still not sure what the right approach is. If its to layer them like so or to use a macro to statically build out a service that can route. |
Just wanted to throw in my use case for this: We have a pretty decent REST setup in go, and one thing that I'm missing with tower-grpc is routing. The biggest part missing would be the ability to add routes later, and then get a list of the routes. Here's what I'd want to write:
|
This will require some sort of service level router.
The text was updated successfully, but these errors were encountered: