pub struct BuildTimeoutSetEvent {
pub set_type: TimeoutSetType,
pub total_times: Option<u32>,
pub timeout: Option<u32>,
pub xm: Option<u32>,
pub alpha: Option<f64>,
pub quantile: Option<f64>,
pub timeout_rate: Option<f64>,
pub close_timeout: Option<u32>,
pub close_rate: Option<f64>,
/* private fields */
}Expand description
Event indicating that the circuit build timeout has changed.
Tor dynamically adjusts its circuit build timeout based on observed circuit construction times. This event is emitted when the timeout value changes, providing insight into network performance.
§Timeout Calculation
Tor uses a Pareto distribution to model circuit build times:
xm- The Pareto Xm parameter (minimum value)alpha- The Pareto alpha parameter (shape)quantile- The CDF cutoff quantile
§Set Types
The set_type indicates why the timeout changed:
TimeoutSetType::Computed- Calculated from observed timesTimeoutSetType::Reset- Reset to default valuesTimeoutSetType::Suspended- Timeout learning suspendedTimeoutSetType::Discard- Discarding learned valuesTimeoutSetType::Resume- Resuming timeout learning
§Example
use stem_rs::events::BuildTimeoutSetEvent;
fn handle_timeout(event: &BuildTimeoutSetEvent) {
if let Some(timeout) = event.timeout {
println!("Circuit timeout set to {}ms ({:?})", timeout, event.set_type);
}
if let Some(rate) = event.timeout_rate {
println!("Timeout rate: {:.2}%", rate * 100.0);
}
}§See Also
TimeoutSetType- Timeout change reasons
Fields§
§set_type: TimeoutSetTypeType of timeout change.
total_times: Option<u32>Number of circuit build times used to calculate timeout.
timeout: Option<u32>Circuit build timeout in milliseconds.
xm: Option<u32>Pareto Xm parameter in milliseconds.
alpha: Option<f64>Pareto alpha parameter.
quantile: Option<f64>CDF quantile cutoff point.
timeout_rate: Option<f64>Ratio of circuits that timed out.
close_timeout: Option<u32>Duration to keep measurement circuits in milliseconds.
close_rate: Option<f64>Ratio of measurement circuits that were closed.
Implementations§
Source§impl BuildTimeoutSetEvent
impl BuildTimeoutSetEvent
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses a build timeout set event from raw control protocol content.
§Arguments
content- The event content after the event type
§Event Format
SetType [TOTAL_TIMES=...] [TIMEOUT_MS=...] [XM=...] [ALPHA=...]
[CUTOFF_QUANTILE=...] [TIMEOUT_RATE=...] [CLOSE_MS=...] [CLOSE_RATE=...]§Errors
Returns Error::Protocol if:
- The set type is missing or unrecognized
- Numeric values cannot be parsed
Trait Implementations§
Source§impl Clone for BuildTimeoutSetEvent
impl Clone for BuildTimeoutSetEvent
Source§fn clone(&self) -> BuildTimeoutSetEvent
fn clone(&self) -> BuildTimeoutSetEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more