1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Federation configuration types and structures
use serde::{Deserialize, Serialize};
/// Remote GraphQL service endpoint configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteEndpoint {
/// Service identifier
pub id: String,
/// GraphQL endpoint URL
pub url: String,
/// Optional authentication header
pub auth_header: Option<String>,
/// Service namespace for type prefixing
pub namespace: Option<String>,
/// Timeout in seconds
pub timeout_secs: u64,
/// Maximum retry attempts for failed requests
pub max_retries: u32,
/// Retry backoff strategy
pub retry_strategy: RetryStrategy,
/// Health check endpoint (optional)
pub health_check_url: Option<String>,
/// Service priority (higher priority services are preferred)
pub priority: i32,
/// Schema version for backward compatibility tracking
pub schema_version: Option<String>,
/// Minimum compatible version with this service
pub min_compatible_version: Option<String>,
}
/// Retry strategy for failed requests
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RetryStrategy {
/// No retries
None,
/// Fixed delay between retries
FixedDelay { delay_ms: u64 },
/// Exponential backoff with jitter
ExponentialBackoff {
initial_delay_ms: u64,
max_delay_ms: u64,
multiplier: f64,
},
}
/// Federation configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FederationConfig {
/// Remote endpoints to federate
pub endpoints: Vec<RemoteEndpoint>,
/// Enable schema caching
pub enable_schema_cache: bool,
/// Schema cache TTL in seconds
pub schema_cache_ttl: u64,
/// Enable query result caching
pub enable_result_cache: bool,
/// Query result cache TTL in seconds
pub result_cache_ttl: u64,
/// Maximum federation depth for nested queries
pub max_federation_depth: usize,
}
impl Default for FederationConfig {
fn default() -> Self {
Self {
endpoints: Vec::new(),
enable_schema_cache: true,
schema_cache_ttl: 3600, // 1 hour
enable_result_cache: true,
result_cache_ttl: 300, // 5 minutes
max_federation_depth: 3,
}
}
}