Conversation
Currently, `ServiceExt::oneshot` is used to take a `Service` by value, poll it until it's ready, and then call that service. This composes well with `Service` middleware, but it does not compose with our `Proxy` trait. If a `Service` must be wrapped in a `Proxy` call, it is impossible to oneshot it. This branch adds a new `Proxy::proxy_oneshot` method to `Proxy` that takes a `Proxy` and a `Service` by value, and returns a `Future` that drives the `Service` to readiness and then calls it through that `Proxy`. Currently, this is unused, but it will be used in PR #1706 (from which this change was factored out).
hawkw
added a commit
that referenced
this pull request
Jun 1, 2022
This branch adds a `Proxy::into_service` method that composes a `Proxy` with a `Service`, returning a new `Service` that calls the inner `Service` through that `Proxy`. This negates the need for `Proxy::proxy_oneshot`, so this also closes #1725. Currently, this is unused, but it will be used in PR #1706 (from which this change was factored out).
olix0r
reviewed
Jun 3, 2022
Comment on lines
+23
to
+25
| /// Like [`ServiceExt::oneshot`](tower::util::ServiceExt::oneshot), but with | ||
| /// a `Proxy` too. | ||
| fn proxy_oneshot(self, svc: S, req: Req) -> Oneshot<Self, S, Req> |
Member
There was a problem hiding this comment.
I'm not necessarily opposed to this but I'm having a little trouble understanding the use case. The whole point of a proxy is to take a service by-reference. It sounds like what we really want is to fuse the proxy to a service in this case?
Member
|
Can this be closed in favor of #1726? |
Contributor
Author
Yes, should have just closed it. |
hawkw
added a commit
that referenced
this pull request
Jun 3, 2022
…1726) This branch adds a `Proxy::into_service` method that composes a `Proxy` with a `Service`, returning a new `Service` that calls the inner `Service` through that `Proxy`. This negates the need for `Proxy::proxy_oneshot`, so this also closes #1725. Currently, this is unused, but it will be used in PR #1706 (from which this change was factored out). Signed-off-by: Eliza Weisman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
ServiceExt::oneshotis used to take aServiceby value,poll it until it's ready, and then call that service. This composes well
with
Servicemiddleware, but it does not compose with ourProxytrait. If a
Servicemust be wrapped in aProxycall, it isimpossible to oneshot it.
This branch adds a new
Proxy::proxy_oneshotmethod toProxythattakes a
Proxyand aServiceby value, and returns aFuturethatdrives the
Serviceto readiness and then calls it through thatProxy.Currently, this is unused, but it will be used in PR #1706 (from which
this change was factored out).