pub fn retry(&mut self) -> bool {
        if self.trips.len() < self.count {
            // haven't retried enough times to trip yet
            self.trips.push(Utc::now());
            true
        } else {
            debug_assert!(self.trips.len() == self.count);

            let now = Utc::now();
            if now - self.trips[0] < self.duration {
                // earliest trip was too recent - trip the breaker
                false
            } else {
                // remove the oldest retry and record the current one, breaker remains closed
                self.trips.remove(0);
                self.trips.push(now);
                true
            }
        }
    }
/// check if the circuit breaker will allow us to retry an operation.
/// This method compares the current time to the oldest time in the
/// last `count` retries - if this time is less than `duration` then it returns `false`
/// otherwise the current time is recorded and it returns `true`
check if the circuit breaker will allow us to retry an operation.
check if the circuit breaker will allow us to retry an operation .
pub fn retry(&mut self) -> bool {
        if self.trips.len() < self.count {
            // haven't retried enough times to trip yet
            self.trips.push(Utc::now());
            true
        } else {
            debug_assert!(self.trips.len() == self.count);
            let now = Utc::now();
            if now - self.trips[0] < self.duration {
                // earliest trip was too recent - trip the breaker
                false
            } else {
                // remove the oldest retry and record the current one, breaker remains closed
                self.trips.remove(0);
                self.trips.push(now);
                true
            }
        }
    }
pub fn retry ( & mut self ) -> bool { if self . trips . len ( ) < self . count { // haven't retried enough times to trip yet self . trips . push ( Utc :: now ( ) ) ; true } else { debug_assert ! ( self trips len ( ) self count ) ; let now = Utc :: now ( ) ; if now - self . trips [ 0 ] < self . duration { // earliest trip was too recent - trip the breaker false } else { // remove the oldest retry and record the current one, breaker remains closed self . trips . remove ( 0 ) ; self . trips . push ( now ) ; true } } }
check if the circuit breaker will allow us to retry an operation.
check if the circuit breaker will allow us to retry an operation .
&mut self