Struct Hedge
pub struct Hedge<S, P>(/* private field */);
A middleware that pre-emptively retries requests which have been outstanding for longer than a given latency percentile. If either of the original future or the retry future completes, that value is used.
Implementations
impl<S, P> Hedge<S, P>
fn new<Request>(service: S, policy: P, min_data_points: u64, latency_percentile: f32, period: Duration) -> Hedge<S, P> where S: Service<Request> + Clone, S::Error: Into<BoxError>, P: Policy<Request> + Clone,Create a new hedge middleware.
fn new_with_mock_latencies<Request>(service: S, policy: P, min_data_points: u64, latency_percentile: f32, period: Duration, latencies_ms: &[u64]) -> Hedge<S, P> where S: Service<Request> + Clone, S::Error: Into<BoxError>, P: Policy<Request> + Clone,A hedge middleware with a prepopulated latency histogram. This is usedful for integration tests.
Trait Implementations
impl<S, P, Request> Service<Request> for Hedge<S, P>
where
S: Service<Request> + Clone,
S::Error: Into<BoxError>,
P: Policy<Request> + Clone,
type Response = <S as Service<Request>>::Response;type Error = Box<dyn Error + Sync + Send>;type Future = Future<Select<SelectPolicy<P>, Latency<Arc<Mutex<RotatingHistogram>>, S>, Delay<DelayPolicy, AsyncFilter<Latency<Arc<Mutex<RotatingHistogram>>, S>, PolicyPredicate<P>>>>, Request>;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, request: Request) -> Self::Future
impl<S: Debug, P: Debug> Debug for Hedge<S, P>
fn fmt(&self, f: &mut Formatter<'_>) -> Result