-
Notifications
You must be signed in to change notification settings - Fork 283
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
Consider making Either uniform with futures::Either #550
Comments
Yeah I think thats a good idea.
There is a bit more to tower's |
Does it need to? I.e. if we inherit the Future impl, can it be used for our needs to satisfy |
As discussed in #629, we should probably update the |
In practice I've found `Either` be hard to use since it changes the error type to `BoxError`. That means if you combine two infallible services you get a service that, to the type system, is fallible. That doesn't work well with [axum's error handling](https://docs.rs/axum/latest/axum/error_handling/index.html) model which requires all services to be infallible and thus always return a response. So you end up having to add boilerplate just to please the type system. Additionally, the fact that `Either` implements `Future` also means we cannot fully remove the dependency on `pin-project` since `pin-project-lite` doesn't support tuple enum variants, only named fields. This PR reworks `Either` to address these: - It now requires the two services to have the same error type so no type information is lost. I did consider doing something like `where B::Error: From<A::Error>` but I hope this simpler model will lead to better compiler errors. - Changes the response future to be a struct with a private enum using `pin-project-lite` - Removes the `Future` impl so we can remove the dependency on `pin-project` Goes without saying that this is a breaking change so we have to wait until tower 0.5 to ship this. cc @jplatte Fixes #594 Fixes #550
The
tower::Either
behaves similarly tofutures::Either
, but they've diverged over time. Namely, tower's is:but future's is now:
futures::Either
type and provideService
impls for it?The text was updated successfully, but these errors were encountered: