-
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
Expose into_service
functions that provide Sync and/or Clone Services
#1322
Comments
Oh this sounded like a fun one to explore :) I am not sure if we want to provide all those methods. I think the issue in the first place is that poem requires sync when you shouldn't need it. Tonic originally required sync for all services but that was deemed a mistake. I would maybe reach out there and see if they would allow you to remove that restriction? |
Okay I can continue this investigation with Poem :) |
Unfortunately so far no cigar on the Poem side, so this problem remains. Can you think of any other way to get these two webserver frameworks to work together without having to run them both separately and put a reverse proxy in front? |
Ok one suggestion would be to avoid using the tonic server all together just use the service directly. I realize the multiplex example uses If you need a router, I would implement that manually. Each generated |
Feature Request
Motivation
I have the following code:
In this code you see that I have a Tonic service which I convert into a Tower service. I then run it through this compat function from Poem so I can use it with Poem. The problem is that compat function (https://docs.rs/poem/latest/poem/endpoint/trait.TowerCompatExt.html) requires that the service be Sync, but tonic services are not Sync. Diving deeper, it is not as simple as making the Service Sync in tonic, that doesn't work. However when I look at Tower, I see that they have this BoxService which is Sync (tower-rs/tower#702). But with that I'm also having a variety of problems, because that isn't Clone (another requirement).
In any case, getting a Service that is either Clone or Sync is possible using these various utilities from Tower. IT seems like getting one that is both Clone and Sync is also possible, but TBA on that: tower-rs/tower#691. See also tower-rs/tower#663.
Proposal
So the request here is for Tonic to provide functions that give you these different Services out of the box. Figuring all this out took quite a while, it'd be nice if future Tonic users didn't have to worry about this and could just use functions like this:
into_service
: Already exists.into_service_sync
: Likeinto_service
but the service is Sync.into_service_clone
: Likeinto_service
but the service is Clone.into_service_sync_clone
: Likeinto_service
but the service is Sync + Clone.Under the hood Tonic would utilize all these Tower utilities for us.
Alternatives
Users can do it all on their own after getting the service from
into_service
, but it is quite complicated. It'd be nice if this was just possible out of the box.The text was updated successfully, but these errors were encountered: