hive-router 0.2.0

GraphQL router for Federation, part of the Hive platform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use retry_policies::policies::ExponentialBackoff as RetryPoliciesExponentialBackoff;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct RetryPolicyConfig {
    /// The maximum number of retries to attempt.
    ///
    /// Retry mechanism is based on exponential backoff, see https://docs.rs/retry-policies/latest/retry_policies/policies/struct.ExponentialBackoff.html for additional details.
    pub max_retries: u32,
}

impl From<&RetryPolicyConfig> for RetryPoliciesExponentialBackoff {
    fn from(config: &RetryPolicyConfig) -> Self {
        RetryPoliciesExponentialBackoff::builder().build_with_max_retries(config.max_retries)
    }
}