Skip to content

Commit

Permalink
feat(proxy): remove lifetime from request future
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjentix authored and loyd committed Dec 17, 2024
1 parent b3392a3 commit 01b179c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions elfo-test/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ impl Proxy {

/// See [`Context::request()`] for details.
#[track_caller]
pub fn request<R: Request>(&self, request: R) -> impl Future<Output = R::Response> + '_ {
pub fn request<R: Request>(&self, request: R) -> impl Future<Output = R::Response> {
let location = Location::caller();
let context = self.context.pruned();
self.scope.clone().within(async move {
let name = request.name();
match self.context.request(request).resolve().await {
match context.request(request).resolve().await {
Ok(response) => response,
Err(err) => panic!("cannot send {} ({}) at {}", name, err, location),
}
Expand All @@ -115,11 +116,12 @@ impl Proxy {
&self,
recipient: Addr,
request: R,
) -> impl Future<Output = R::Response> + '_ {
) -> impl Future<Output = R::Response> {
let location = Location::caller();
let context = self.context.pruned();
self.scope.clone().within(async move {
let name = request.name();
match self.context.request_to(recipient, request).resolve().await {
match context.request_to(recipient, request).resolve().await {
Ok(response) => response,
Err(err) => panic!("cannot send {} ({}) at {}", name, err, location),
}
Expand Down

0 comments on commit 01b179c

Please sign in to comment.