feat(client): add --timeouts option for session-opening retry schedule
This commit is contained in:
4 files changed
+27
-11
No files matched your search
@@ -22,6 +22,10 @@ pub struct CommonClientArgs {
|
||||
#[arg(short = 'i', long, default_value = "1s", value_parser = parse_duration)]
|
||||
pub interval: Duration,
|
||||
|
||||
/// Comma-separated session-opening timeouts, one per attempt (each >= 200ms).
|
||||
#[arg(long, value_name = "DURATIONS", value_delimiter = ',', value_parser = parse_duration, long_help = "Comma-separated session-opening receive timeouts, one per attempt (each at least 200ms), e.g. 1s,2s,4s,8s. Omit to use the library default retry schedule.")]
|
||||
pub timeouts: Vec<Duration>,
|
||||
|
||||
/// UDP payload length.
|
||||
#[arg(short = 'l', long, default_value_t = 0, value_parser = parse_length)]
|
||||
pub length: u32,
|
||||
@@ -116,6 +120,7 @@ impl fmt::Debug for CommonClientArgs {
|
||||
.field("ipv6", &self.ipv6)
|
||||
.field("dual_stack", &self.dual_stack)
|
||||
.field("interval", &self.interval)
|
||||
.field("timeouts", &self.timeouts)
|
||||
.field("length", &self.length)
|
||||
.field("hmac", &self.hmac.as_ref().map(|_| "[REDACTED]"))
|
||||
.field("clock", &self.clock)
|
||||
|
||||
@@ -22,16 +22,21 @@ impl CommonClientArgs {
|
||||
///
|
||||
/// The config is endpoint-independent; managed targets own their addresses.
|
||||
pub fn to_client_config(&self, duration: Duration) -> Result<ClientConfig, String> {
|
||||
let mut open = OpenPolicy {
|
||||
negotiation: if self.loose {
|
||||
NegotiationPolicy::Loose
|
||||
} else {
|
||||
NegotiationPolicy::Strict
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
if !self.timeouts.is_empty() {
|
||||
open.timeouts.clone_from(&self.timeouts);
|
||||
}
|
||||
|
||||
Ok(ClientConfig {
|
||||
address_family: self.address_family(),
|
||||
open: OpenPolicy {
|
||||
negotiation: if self.loose {
|
||||
NegotiationPolicy::Loose
|
||||
} else {
|
||||
NegotiationPolicy::Strict
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
open,
|
||||
request: SessionRequest {
|
||||
duration: (!duration.is_zero()).then_some(duration),
|
||||
interval: self.interval,
|
||||
|
||||
Reference in new issue
Block a user