-
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
Conditionaly adding services to router #265
Comments
So I unfortunately think this is not possible right now due to our https://docs.rs/tonic/0.1.1/tonic/transport/trait.NamedService.html#associatedconstant.NAME trait since it contains a const type. This makes it hard to implement So to implement this we would need to make a breaking change. So I'm curious if maybe using a macro could help here? If you end up running into many branches you may wan to use another type of router than the one tonic provides. |
@LucioFranco I think a macro would be great substitute as long as n isn't too large, yes. I appreciate the modularity of tonic allowing me to switch out the router if I wish. Wondering about another possibility: |
I am not sure that will work but I'd be open to a PR for that! |
Feature Request
Motivation
I have a server which will enjoy up to 5 different services, each of which should be able to be enable/disabled at boot time. Currently there seems to be no way to do this without 2^5 different branches.
Proposal
Diesel has a similar problem when conditionally constructing queries, their solution is to provide a into_boxed() method.
A similar method could be added to Router.
A subsequent problem is that there is no way to generate a router with no services from a
Server
- this would also be required to conditionally add services. This could be done via a into_router() method on the Server.The potential drawbacks here are that doing this may have unintended overhead due to the required boxing?
The text was updated successfully, but these errors were encountered: