pub trait Upstream<Req> {
type Response;
type Future: Future<Output = Self::Response> + Send;
// Required method
fn call(&mut self, req: Req) -> Self::Future;
}Expand description
Trait for calling upstream services with cacheable requests.
This trait is framework-agnostic and can be implemented for any async service.
§Examples
ⓘ
use hitbox_core::Upstream;
use std::future::Ready;
struct MockUpstream {
response: MyResponse,
}
impl Upstream<MyRequest> for MockUpstream {
type Response = MyResponse;
type Future = Ready<Self::Response>;
fn call(&mut self, _req: MyRequest) -> Self::Future {
std::future::ready(self.response.clone())
}
}