hyperstack_sdk/
config.rs

1use crate::store::DEFAULT_MAX_ENTRIES_PER_VIEW;
2use std::time::Duration;
3
4#[derive(Debug, Clone)]
5pub struct HyperStackConfig {
6    pub auto_reconnect: bool,
7    pub reconnect_intervals: Vec<Duration>,
8    pub max_reconnect_attempts: u32,
9    pub ping_interval: Duration,
10    pub initial_data_timeout: Duration,
11    pub max_entries_per_view: Option<usize>,
12}
13
14impl Default for HyperStackConfig {
15    fn default() -> Self {
16        Self {
17            auto_reconnect: true,
18            reconnect_intervals: vec![
19                Duration::from_secs(1),
20                Duration::from_secs(2),
21                Duration::from_secs(4),
22                Duration::from_secs(8),
23                Duration::from_secs(16),
24            ],
25            max_reconnect_attempts: 5,
26            ping_interval: Duration::from_secs(15),
27            initial_data_timeout: Duration::from_secs(5),
28            max_entries_per_view: Some(DEFAULT_MAX_ENTRIES_PER_VIEW),
29        }
30    }
31}
32
33#[derive(Debug, Clone)]
34pub struct ConnectionConfig {
35    pub auto_reconnect: bool,
36    pub reconnect_intervals: Vec<Duration>,
37    pub max_reconnect_attempts: u32,
38    pub ping_interval: Duration,
39}
40
41impl From<HyperStackConfig> for ConnectionConfig {
42    fn from(config: HyperStackConfig) -> Self {
43        Self {
44            auto_reconnect: config.auto_reconnect,
45            reconnect_intervals: config.reconnect_intervals,
46            max_reconnect_attempts: config.max_reconnect_attempts,
47            ping_interval: config.ping_interval,
48        }
49    }
50}
51
52impl Default for ConnectionConfig {
53    fn default() -> Self {
54        HyperStackConfig::default().into()
55    }
56}