-
Notifications
You must be signed in to change notification settings - Fork 282
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
path to tower-service 1.0 #636
Comments
I went ahead and assigned everyone who might have opinions on this, hope that's not too annoying. :) |
Quick ping — how do other maintainers (especially @seanmonstar, since it's potentially relevant to |
I think your proposal sounds good! I'm up for helping investigating the proposed changes and porting tower-http and axum to see how they work in practice. One thing though: It all depends on the timeline that we agree on but I don't think we should necessarily wait for new features to stabilise in Rust. I think we should focus on coming up with a design that makes sense given what Rust looks like today, otherwise I'm afraid we'll never ship 😕 I also think we should consider a 1.0 of
|
I think this makes a lot of sense. I believe most of the features we are waiting on are almost ready (and should be on nightly). My main question though is we should 1.0 tower with hyper, so @seanmonstar how close is hyper to something like a 1.0? |
Yeah, I strongly agree with this. I think we should investigate the suggested changes that are potentially possible today, see if they work, and not worry about the Shiny Future too much. If there are significant language changes that impact the design of
Yeah, I agree; I left that out of this issue because it seemed out of scope. Fortunately, though, I think stabilizing
Hmm, what language features are you thinking about here? If you mean
I think the point here is that if |
I'd like to add another note https://github.com/awslabs/smithy-rs/ is a pretty big consumer of tower so we should also consider their use.
Yeah I am thinking GAT for the token style. So this would align with the splitting the ready and call part of the
Our goal should be 100% to have hyper 1.0 with Service imo. In addition, I think the big pain point with tower is |
This year. It's a team goal.
This is also true, and potentially still an option anyways. Whether hyper would come up with it's own trait, ditch the service pattern entirely for an accept/pull pattern, or anything else... hyper definitely couldn't depend on |
Right, my point is we should use hypers timeline to ensure that we 1.0 for inclusion into hypers 1.0 release. I think it would be pretty important ecosystem wise to accomplish that. |
I agree with that 👍 |
I've filed #657 which I think we should at least consider as part of tower-service 1.0 |
Apologize for my ignorance, but with GATs right around the corner, tower 1.0 will likely want to change the service trait ala https://tokio.rs/blog/2021-05-14-inventing-the-service-trait#gats, correct? |
GATs have been right around the corner for a long time 😅 I'm also not sure anyone has done a serious attempt at porting stuff to a GAT based service trait, yet at least. |
Also, the specific note in the blog post you linked to suggests that GATs would allow us to remove the Note that because the Also, note that futures will need to live for the |
IMO, the main reason GATs are actually desirable for |
Token types should allow call to take |
It looks to me like the reason why #412 had been postponed is that the next batch of changes would happen when GATs stabilize. Given it doesn't seem to be the case anymore, would now be the right time to have an other look at it, and try to get it in? Or do we feel like we still need GATs in order to "get disarm right" ? |
With GATs happening (rust-lang/rust#96709 (comment) ), it might be good to make some of the proposed changes to tower, at the very least to give feedback on GATs before final release? |
FYI GATs are now stable as of Rust 1.65.0. |
FYI I am doing some work w/ async_fn in traits feature on nightly. Will eventually report back but since that feature is landing much sooner than I thought I think we should wait for that to land to 1.0 tower. |
I believe the lack of Send bounds would need to be resolved for async fn in traits to be suitable for tower. |
@leoyvens correct, I've already communicated this to the async wg. |
I'd love to at least see a lifetime GAT added to the |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey folks, I was looking around the state of async traits in Rust and encountered this page: Which is essentially a case study of how the use of async traits can simplify the trait Service<Request> {
type Response;
async fn call(&self, request: Request) -> Self::Response;
} I am aware, that with current state of the Rust such shape poses some limitations, mainly:
However, both of these problems will eventually be solved by the language:
Both of these enhancements are planned to be available with the Rust Edition 2024. With above being said, I am just curious what are your plans towards the eventual stabilization of Is the simplified shape of service trait proposed in the case study even a possibility? Would you consider embracing the modern Rust lang features and introducing a breaking change to Thanks a lot for your time and an answer! |
Motivation
Tower has been used in production for over three years. Since the
Service
trait is intended to provide a common abstraction and compatibility interface across libraries, the definition of theService
trait is factored out into thetower-service
crate so that it can remain stable even as other parts of the Tower ecosystem are changed. A significant number of major crates depend ontower-service
, includinghyper
,tonic
,warp
, andaxum
. In most cases, these are public API dependencies. This means that these crates cannot currently release 1.0 versions while they exposetower-service
in their public APIs.The last time a breaking change was made to the
Service
trait was November 2019; this was in order to transition fromfutures
0.1 tostd::future
. While there have been a number of proposed improvements to theService
trait (e.g. #110, #136, #137, #319, #408, #412, #626), most of these have not ended up being practical, or require future language features that are not currently available on stable Rust.Therefore, I think it's time to have a serious conversation about stabilizing the
Service
trait.Proposal
In order to stabilize
tower-service
, I think we should do the following:tower-service
and wish to release 1.0 versions (e.g.hyper
).Service
trait changes. Before stabilizingService
exactly as it exists right now, we should look into all the potential breaking changes that have been suggested, investigate whether they are possible, and assess the potential benefits of making them. This includes ideas likeService::disarm
, tokens, splittingService
intoPollReady
andCall
traits, etc. I think the best way to assess these ideas is to actually implement them in a branch. To really determine the benefits and drawbacks of these changes, it would probably also be good to fork a crate that usestower-service
, and try to update it to use the modified version. If this isn't practical, we should at least try to update a non-trivial example project; at the very least, we should be able to test outtower::balance
and get the load-balancing example to work.Once we stabilize
tower-service
, we may want to consider the path to stability fortower-layer
as well, but I think that's not as important.Outstanding questions
Service
trait actually look like?Service
's blanket impl for? See service: ImplService
forasync
functions #657The text was updated successfully, but these errors were encountered: