Skip to main content

elfo_pinger/
config.rs

1//! Configuration for the pinger.
2//!
3//! Note: all types here are exported only for documentation purposes
4//! and are not subject to stable guarantees. However, the config
5//! structure (usually encoded in TOML) follows stable guarantees.
6
7use std::time::Duration;
8
9use serde::Deserialize;
10
11/// The pinger's config.
12///
13/// # Example
14/// ```toml
15/// [system.pingers]
16/// ping_interval = "30s"
17/// ```
18#[derive(Debug, Deserialize)]
19pub struct Config {
20    /// How often pingers should ping all other actors.
21    ///
22    /// `10s` by default.
23    #[serde(with = "humantime_serde", default = "default_ping_interval")]
24    pub ping_interval: Duration,
25    /// How long to wait for a response before logging a warning.
26    ///
27    /// `5s` by default.
28    #[serde(with = "humantime_serde", default = "default_warn_threshold")]
29    pub warn_threshold: Duration,
30}
31
32fn default_ping_interval() -> Duration {
33    Duration::from_secs(10)
34}
35
36fn default_warn_threshold() -> Duration {
37    Duration::from_secs(5)
38}