Skip to main content

flow_bot/base/
connect.rs

1/// Reconnection strategy configuration
2#[derive(Clone, Debug)]
3pub enum ReconnectionStrategy {
4    /// Reconnect endlessly with exponential backoff
5    Infinite {
6        /// Initial delay in milliseconds (default: 1000)
7        initial_delay_ms: u64,
8        /// Maximum delay in milliseconds (default: 60000)
9        max_delay_ms: u64,
10    },
11    /// Reconnect for a limited number of attempts
12    Limited {
13        /// Maximum number of reconnection attempts
14        max_attempts: u32,
15        /// Initial delay in milliseconds (default: 1000)
16        initial_delay_ms: u64,
17        /// Maximum delay in milliseconds (default: 60000)
18        max_delay_ms: u64,
19    },
20    /// Do not reconnect
21    None,
22}
23
24impl Default for ReconnectionStrategy {
25    fn default() -> Self {
26        Self::Infinite {
27            initial_delay_ms: 1000,
28            max_delay_ms: 60000,
29        }
30    }
31}
32
33/// Currently only WsReverse is supported. I do not intend to implement more but PRs are welcome.
34#[derive(Clone)]
35pub struct ReverseConnectionConfig {
36    pub target: String,
37    pub auth: Option<String>,
38    pub reconnection: ReconnectionStrategy,
39}