-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Switching to tower::Service #1782
Comments
First, I am really excited for this! So at a high level, is it worth it right now to introduce kinda a halfway there approach instead of going all in and releasing For me the biggest things I'd like to see in the transition to tower is:
That said, with the For the clients, I'm not totally sure what the right path is for them as well. I have been going back and forth between providing a All in all, Im really excited to move this forward but I still think there are some unanswered questions still in tower itself around what is a client, does it provide a |
And to add something else, at work we have been using the |
Oh that's right, thanks for reminding me. I think that change is a little trickier:
The issue this creates is that in order for something to be both a |
I think |
These thoughts aren't complete, nor are they particularly well-edited, but here goes:
I can't comment on the BufStream/Body stuff as I don't have enough context or expertise on the matter. |
@seanmonstar could we add an |
I haven't tried, but I don't believe we can implement a blanket implementation of a foreign trait in hyper... |
Roughly, I think the proposed step of introducing Tower support without introducing any breaking changes is good. This would add initial support while we figure out the best "breaking change" API. Looking at I think there may be an alternate way to add support for You don't have a bound on I do think that we should explore what an 0.13 API may look like more in |
This comment has been minimized.
This comment has been minimized.
I see this is listed under the 0.13 milestone, what work remains to be done for this issue? |
I think it's mostly done! |
We've been working a while on tower, feel like
tower-service
0.2 has stabilized, so that it's becoming reasonable for hyper to depend on it without worrying about rapid breaking changes.hyper 0.12 current has its own
Service
trait which was inspired by earlier versions of tower, mostly so that hyper didn't need to commit to breaking changes from tower while we iterated. Now seems like a good time to "switch". But how?Well, we can't just swap the traits directly, as that is a breaking change. Instead, the direct swap will need to happen in hyper 0.13. In the meantime, we can provide an easy utility directly in hyper to convert
tower::Service
s tohyper::Service
s.A
hyper::service::tower
utilityhyper::service::tower()
function that takes atower::Service
(with the appropriate associated types) and wraps it into ahyper::Service
. This allows easily converting in any place that needs ahyper::Service
, such ashyper::server::conn::Http::serve_connection
.hyper::service::tower::make()
function that essentially takes atower::MakeService
and creates ahyper::service::MakeService
. We won't actually have the bounds use tower'sMakeService
, but that's just to not depend on the less stabletower-service-util
.Example
This ends allowing code like this:
Implement
tower::Service
for client stufftower::Service
forhyper::client::conn::SendRequest
.hyper::Client
should be. Is it aService
? Sorta, you can send requests and get responses. But internally it manages a connection pool (well, aService
pool?). But it's not really aMakeService
either, as it doesn't have a way to hand out those pooledService
s, it just uses them internally...Questions
Service
forClient
orhyper::client::conn::SendRequest
make it harder for those to eventually convert toasync fn
? Yea kinda, as we could no longer put those opaque future types in the associated types ofService
, at least not until trait existential types is stable.Service
directly, but to add someinto_service(self) -> impl Service
methods. That way does allow the opaque types in the associated types.impl Service
externally, which is still frequently done...The text was updated successfully, but these errors were encountered: