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
// Connection and timeout configuration arguments
// Copyright (C) 2025 Marc Rivero (@seifreed)
// Licensed under GPL-3.0
use clap::Args;
/// Connection and timeout configuration options
///
/// This struct contains all arguments related to connection timeouts,
/// retry logic, and connection timing behavior.
#[derive(Args, Debug, Clone)]
pub struct ConnectionArgs {
/// Socket timeout in seconds
#[arg(long = "socket-timeout", value_name = "SECONDS")]
pub socket_timeout: Option<u64>,
/// Connection timeout in seconds (separate from socket timeout)
#[arg(long = "connect-timeout", value_name = "SECONDS")]
pub connect_timeout: Option<u64>,
/// Sleep between connection requests in milliseconds
#[arg(long = "sleep", value_name = "MSEC")]
pub sleep: Option<u64>,
/// Delay between connections (e.g "200ms", "1s")
#[arg(long = "delay")]
pub delay: Option<String>,
/// Maximum number of retries for transient network failures (0 = no retries)
/// Helps distinguish between permanent failures (connection refused) and
/// transient failures (timeouts, connection resets)
#[arg(long = "max-retries", value_name = "COUNT", default_value = "3")]
pub max_retries: usize,
/// Initial backoff duration in milliseconds for retry logic
/// Backoff doubles with each retry (exponential backoff) up to max-backoff
#[arg(long = "retry-backoff", value_name = "MSEC", default_value = "100")]
pub retry_backoff_ms: u64,
/// Maximum backoff duration in milliseconds for retry logic
/// Prevents excessive delays during multiple retries
#[arg(long = "max-backoff", value_name = "MSEC", default_value = "5000")]
pub max_backoff_ms: u64,
/// Disable retry logic (fail immediately on first error)
/// Equivalent to --max-retries 0
#[arg(long = "no-retry")]
pub no_retry: bool,
}
impl Default for ConnectionArgs {
fn default() -> Self {
Self {
socket_timeout: None,
connect_timeout: None,
sleep: None,
delay: None,
max_retries: 3,
retry_backoff_ms: 100,
max_backoff_ms: 5000,
no_retry: false,
}
}
}