Skip to content

stack: add Proxy::proxy_oneshot#1725

Closed
hawkw wants to merge 1 commit intomainfrom
eliza/proxy-oneshot
Closed

stack: add Proxy::proxy_oneshot#1725
hawkw wants to merge 1 commit intomainfrom
eliza/proxy-oneshot

Conversation

@hawkw
Copy link
Contributor

@hawkw hawkw commented Jun 1, 2022

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).

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 hawkw requested a review from a team as a code owner June 1, 2022 17:45
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).
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@olix0r
Copy link
Member

olix0r commented Jun 3, 2022

Can this be closed in favor of #1726?

@hawkw
Copy link
Contributor Author

hawkw commented Jun 3, 2022

Can this be closed in favor of #1726?

Yes, should have just closed it.

@hawkw hawkw closed this Jun 3, 2022
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]>
@olix0r olix0r deleted the eliza/proxy-oneshot branch March 7, 2023 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants