diff --git a/commons/zenoh-config/src/connection_retry.rs b/commons/zenoh-config/src/connection_retry.rs index 55234dcc91..80aa5334bb 100644 --- a/commons/zenoh-config/src/connection_retry.rs +++ b/commons/zenoh-config/src/connection_retry.rs @@ -16,14 +16,7 @@ use serde::{Deserialize, Serialize}; use zenoh_core::zparse_default; use zenoh_protocol::core::{EndPoint, WhatAmI}; -use crate::{ - defaults::{ - self, DEFAULT_CONNECT_EXIT_ON_FAIL, DEFAULT_CONNECT_TIMEOUT_MS, - DEFAULT_LISTEN_EXIT_ON_FAIL, DEFAULT_LISTEN_TIMEOUT_MS, - }, - mode_dependent::*, - Config, -}; +use crate::{defaults, mode_dependent::*, Config}; #[derive(Debug, Deserialize, Serialize, Clone)] pub struct ConnectionRetryModeDependentConf { @@ -128,7 +121,7 @@ pub fn get_global_listener_timeout(config: &Config) -> std::time::Duration { .listen() .timeout_ms() .get(whatami) - .unwrap_or(DEFAULT_LISTEN_TIMEOUT_MS.get(whatami).unwrap()), + .unwrap_or(defaults::listen::timeout_ms.get(whatami).unwrap()), ) } @@ -139,7 +132,7 @@ pub fn get_global_connect_timeout(config: &Config) -> std::time::Duration { .connect() .timeout_ms() .get(whatami) - .unwrap_or(DEFAULT_CONNECT_TIMEOUT_MS.get(whatami).unwrap()), + .unwrap_or(defaults::connect::timeout_ms.get(whatami).unwrap()), ) } @@ -164,7 +157,7 @@ pub fn get_retry_config( .listen() .exit_on_failure() .get(whatami) - .unwrap_or(DEFAULT_LISTEN_EXIT_ON_FAIL.get(whatami).unwrap()); + .unwrap_or(defaults::listen::exit_on_failure.get(whatami).unwrap()); } else { retry = config .connect() @@ -176,7 +169,7 @@ pub fn get_retry_config( .connect() .exit_on_failure() .get(whatami) - .unwrap_or(DEFAULT_CONNECT_EXIT_ON_FAIL.get(whatami).unwrap()); + .unwrap_or(defaults::connect::exit_on_failure.get(whatami).unwrap()); } let mut res = ConnectionRetryConf::new(whatami, exit_on_failure, retry, default_retry); diff --git a/commons/zenoh-config/src/defaults.rs b/commons/zenoh-config/src/defaults.rs index cc6bf5854a..37fde1050e 100644 --- a/commons/zenoh-config/src/defaults.rs +++ b/commons/zenoh-config/src/defaults.rs @@ -32,6 +32,33 @@ macro_rules! mode_accessor { #[allow(dead_code)] pub const mode: WhatAmI = WhatAmI::Peer; +#[allow(non_upper_case_globals)] +#[allow(dead_code)] +pub mod connect { + use super::{ModeDependentValue, ModeValues}; + + pub const timeout_ms: ModeDependentValue = ModeDependentValue::Dependent(ModeValues { + router: Some(-1), + peer: Some(-1), + client: Some(0), + }); + pub const exit_on_failure: ModeDependentValue = + ModeDependentValue::Dependent(ModeValues { + router: Some(false), + peer: Some(false), + client: Some(true), + }); +} + +#[allow(non_upper_case_globals)] +#[allow(dead_code)] +pub mod listen { + use super::ModeDependentValue; + + pub const timeout_ms: ModeDependentValue = ModeDependentValue::Unique(0); + pub const exit_on_failure: ModeDependentValue = ModeDependentValue::Unique(true); +} + #[allow(non_upper_case_globals)] #[allow(dead_code)] pub mod scouting { @@ -261,23 +288,6 @@ impl Default for AclConfig { } } -pub const DEFAULT_CONNECT_TIMEOUT_MS: ModeDependentValue = - ModeDependentValue::Dependent(ModeValues { - client: Some(0), - peer: Some(-1), - router: Some(-1), - }); - -pub const DEFAULT_CONNECT_EXIT_ON_FAIL: ModeDependentValue = - ModeDependentValue::Dependent(ModeValues { - client: Some(true), - peer: Some(false), - router: Some(false), - }); - -pub const DEFAULT_LISTEN_TIMEOUT_MS: ModeDependentValue = ModeDependentValue::Unique(0); -pub const DEFAULT_LISTEN_EXIT_ON_FAIL: ModeDependentValue = ModeDependentValue::Unique(true); - impl Default for ConnectionRetryModeDependentConf { fn default() -> Self { Self {