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
//! Server configuration.
use std::time::Duration;
/// Configuration for the xDS server.
#[derive(Debug, Clone)]
pub struct ServerConfig {
/// Enable State-of-the-World protocol.
pub enable_sotw: bool,
/// Enable Delta xDS protocol.
pub enable_delta: bool,
/// Maximum concurrent streams per connection.
pub max_concurrent_streams: Option<u32>,
/// Keepalive interval.
pub keepalive_interval: Option<Duration>,
/// Keepalive timeout.
pub keepalive_timeout: Option<Duration>,
/// Maximum request size in bytes.
pub max_request_size: usize,
/// Response compression.
pub compression: CompressionConfig,
/// Grace period for shutdown.
pub grace_period: Duration,
/// Enable health checking.
pub enable_health: bool,
/// Enable metrics.
pub enable_metrics: bool,
/// Enable connection tracking.
pub enable_connection_tracking: bool,
}
impl Default for ServerConfig {
fn default() -> Self {
Self {
enable_sotw: true,
enable_delta: false,
max_concurrent_streams: Some(100),
keepalive_interval: Some(Duration::from_secs(30)),
keepalive_timeout: Some(Duration::from_secs(10)),
max_request_size: 4 * 1024 * 1024, // 4MB
compression: CompressionConfig::default(),
grace_period: Duration::from_secs(30),
enable_health: true,
enable_metrics: true,
enable_connection_tracking: true,
}
}
}
/// Compression configuration.
#[derive(Debug, Clone, Default)]
pub struct CompressionConfig {
/// Enable gzip compression for responses.
pub gzip: bool,
/// Minimum response size to compress (bytes).
pub min_size: usize,
}
impl CompressionConfig {
/// Create with gzip enabled.
pub fn gzip() -> Self {
Self {
gzip: true,
min_size: 1024,
}
}
}