pub fn all_errors_immediately<
    Value: Send + 'static,
    Fut: Future<Item = Value, Error = String>,
    IntoFut: IntoFuture<Future = Fut, Item = Value, Error = String>,
    F: FnMut(T) -> IntoFut + Send + Sync + Clone + 'static,
  >(
    &self,
    f: F,
    times: usize,
  ) -> impl Future<Item = Value, Error = String> {
    let serverset = self.0.clone();
    futures::future::loop_fn(0_usize, move |i| {
      let serverset = serverset.clone();
      let f = f.clone();
      serverset
        .next()
        .and_then(move |(server, token)| {
          futures::future::ok(server).and_then(f).then(move |result| {
            let health = match &result {
              &Ok(_) => Health::Healthy,
              &Err(_) => Health::Unhealthy,
            };
            serverset.report_health(token, health);
            result
          })
        })
        .map(futures::future::Loop::Break)
        .or_else(move |err| {
          if i >= times {
            Err(format!("Failed after {} retries; last failure: {}", i, err))
          } else {
            Ok(futures::future::Loop::Continue(i + 1))
          }
        })
    })
  }
///
/// Runs `f` up to `times` times, taking servers from the underlying serverset.
///
/// Will retry any time `f` produces an error. The underlying serverset may lead to backoff
/// between attempts, but the Retry implementation itself will not.
///
Runs `f` up to `times` times, taking servers from the underlying serverset.
Will retry any time `f` produces an error. The underlying serverset may lead to backoff
between attempts, but the Retry implementation itself will not.
Runs ` f ` up to ` times ` times taking servers from the underlying serverset . Will retry any time ` f ` produces an error . The underlying serverset may lead to backoff between attempts but the Retry implementation itself will not .
pub fn all_errors_immediately<
    Value: Send + 'static,
    Fut: Future<Item = Value, Error = String>,
    IntoFut: IntoFuture<Future = Fut, Item = Value, Error = String>,
    F: FnMut(T) -> IntoFut + Send + Sync + Clone + 'static,
  >(
    &self,
    f: F,
    times: usize,
  ) -> impl Future<Item = Value, Error = String> {
    let serverset = self.0.clone();
    futures::future::loop_fn(0_usize, move |i| {
      let serverset = serverset.clone();
      let f = f.clone();
      serverset
        .next()
        .and_then(move |(server, token)| {
          futures::future::ok(server).and_then(f).then(move |result| {
            let health = match &result {
              &Ok(_) => Health::Healthy,
              &Err(_) => Health::Unhealthy,
            };
            serverset.report_health(token, health);
            result
          })
        })
        .map(futures::future::Loop::Break)
        .or_else(move |err| {
          if i >= times {
            Err(format!("Failed after {} retries; last failure: {}", i, err))
          } else {
            Ok(futures::future::Loop::Continue(i + 1))
          }
        })
    })
  }
pub fn all_errors_immediately < Value : Send + ' static , Fut : Future < Item = Value , Error = String > , IntoFut : IntoFuture < Future = Fut , Item = Value , Error = String > , F : FnMut ( T ) -> IntoFut + Send + Sync + Clone + ' static , > ( & self , f : F , times : usize , ) -> impl Future < Item = Value , Error = String > { let serverset = self . 0 . clone ( ) ; futures :: future :: loop_fn ( 0_usize , move | i | { let serverset = serverset . clone ( ) ; let f = f . clone ( ) ; serverset . next ( ) . and_then ( move | ( server , token ) | { futures :: future :: ok ( server ) . and_then ( f ) . then ( move | result | { let health = match & result { & Ok ( _ ) => Health :: Healthy , & Err ( _ ) => Health :: Unhealthy , } ; serverset . report_health ( token , health ) ; result } ) } ) . map ( futures :: future :: Loop :: Break ) . or_else ( move | err | { if i >= times { Err ( format ! ( " " i err ) ) } else { Ok ( futures :: future :: Loop :: Continue ( i + 1 ) ) } } ) } ) }
Runs `f` up to `times` times, taking servers from the underlying serverset.
Runs ` f ` up to ` times ` times taking servers from the underlying serverset .
&self
f
F
times
usize