aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorGravatar Yujia Qiao <rapiz3142@gmail.com> 2022-11-29 17:41:23 +0800
committerGravatar GitHub <noreply@github.com> 2022-11-29 09:41:23 +0000
commitd216d6380fd46eb853d2211a8da6b1276bf35f11 (patch)
treed87c690e29437a503a17e3560479c749dce419d8 /src/config.rs
parent87d06c91b944262d26798275865cf545c282f058 (diff)
downloadrathole-d216d6380fd46eb853d2211a8da6b1276bf35f11.tar.gz
rathole-d216d6380fd46eb853d2211a8da6b1276bf35f11.tar.zst
rathole-d216d6380fd46eb853d2211a8da6b1276bf35f11.zip
feat: configurable retry interval (#208)
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 8b9cd3d..74015ed 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -13,6 +13,9 @@ use crate::transport::{DEFAULT_KEEPALIVE_INTERVAL, DEFAULT_KEEPALIVE_SECS, DEFAU
const DEFAULT_HEARTBEAT_INTERVAL_SECS: u64 = 30;
const DEFAULT_HEARTBEAT_TIMEOUT_SECS: u64 = 40;
+/// Client
+const DEFAULT_CLIENT_RETRY_INTERVAL_SECS: u64 = 1;
+
/// String with Debug implementation that emits "MASKED"
/// Used to mask sensitive strings when logging
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone)]
@@ -53,6 +56,8 @@ impl Default for TransportType {
}
}
+/// Per service config
+/// All Option are optional in configuration but must be Some value in runtime
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
#[serde(deny_unknown_fields)]
pub struct ClientServiceConfig {
@@ -63,6 +68,7 @@ pub struct ClientServiceConfig {
pub local_addr: String,
pub token: Option<MaskedString>,
pub nodelay: Option<bool>,
+ pub retry_interval: Option<u64>,
}
impl ClientServiceConfig {
@@ -92,6 +98,8 @@ fn default_service_type() -> ServiceType {
Default::default()
}
+/// Per service config
+/// All Option are optional in configuration but must be Some value in runtime
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
#[serde(deny_unknown_fields)]
pub struct ServerServiceConfig {
@@ -185,6 +193,10 @@ fn default_heartbeat_timeout() -> u64 {
DEFAULT_HEARTBEAT_TIMEOUT_SECS
}
+fn default_client_retry_interval() -> u64 {
+ DEFAULT_CLIENT_RETRY_INTERVAL_SECS
+}
+
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, Clone)]
#[serde(deny_unknown_fields)]
pub struct ClientConfig {
@@ -195,6 +207,8 @@ pub struct ClientConfig {
pub transport: TransportConfig,
#[serde(default = "default_heartbeat_timeout")]
pub heartbeat_timeout: u64,
+ #[serde(default = "default_client_retry_interval")]
+ pub retry_interval: u64,
}
fn default_heartbeat_interval() -> u64 {
@@ -266,6 +280,9 @@ impl Config {
bail!("The token of service {} is not set", name);
}
}
+ if s.retry_interval.is_none() {
+ s.retry_interval = Some(client.retry_interval);
+ }
}
Config::validate_transport_config(&client.transport, false)?;