use super::Retry; use tower_layer::Layer; /// Retry requests based on a policy #[derive(Debug, Clone)] pub struct RetryLayer
{ policy: P, } impl
RetryLayer
{ /// Creates a new [`RetryLayer`] from a retry policy. pub const fn new(policy: P) -> Self { RetryLayer { policy } } } impl
Layer for RetryLayer
where P: Clone, { type Service = Retry
; fn layer(&self, service: S) -> Self::Service { let policy = self.policy.clone(); Retry::new(policy, service) } }