Skip to main content

sol_parser_sdk/shredstream/
config.rs

1//! ShredStream 配置
2
3/// ShredStream 客户端配置
4#[derive(Debug, Clone)]
5pub struct ShredStreamConfig {
6    /// 连接超时(毫秒)
7    pub connection_timeout_ms: u64,
8    /// 请求超时(毫秒)
9    pub request_timeout_ms: u64,
10    /// 最大解码消息大小(字节)
11    pub max_decoding_message_size: usize,
12    /// 自动重连延迟(毫秒)
13    pub reconnect_delay_ms: u64,
14    /// 最大重连次数(0 表示无限重连)
15    pub max_reconnect_attempts: u32,
16}
17
18impl Default for ShredStreamConfig {
19    fn default() -> Self {
20        Self {
21            connection_timeout_ms: 8000,
22            request_timeout_ms: 15000,
23            max_decoding_message_size: 1024 * 1024 * 100, // 100MB
24            reconnect_delay_ms: 1000,
25            max_reconnect_attempts: 3,
26        }
27    }
28}
29
30impl ShredStreamConfig {
31    /// 低延迟配置 - 最小化处理延迟
32    pub fn low_latency() -> Self {
33        Self {
34            connection_timeout_ms: 5000,
35            request_timeout_ms: 10000,
36            max_decoding_message_size: 1024 * 1024 * 50,
37            reconnect_delay_ms: 100,
38            max_reconnect_attempts: 1,
39        }
40    }
41
42    /// 高吞吐配置 - 优化批量处理
43    pub fn high_throughput() -> Self {
44        Self {
45            connection_timeout_ms: 10000,
46            request_timeout_ms: 30000,
47            max_decoding_message_size: 1024 * 1024 * 200,
48            reconnect_delay_ms: 2000,
49            max_reconnect_attempts: 5,
50        }
51    }
52}