Skip to content

Commit

Permalink
Use client multicast autoconnect config (#1712)
Browse files Browse the repository at this point in the history
* Use scouting/multicast/autoconnect/client config

* Update default config to maintain client behavior

* Update default gossip config for clients
  • Loading branch information
oteffahi authored Jan 15, 2025
1 parent 13b5af6 commit 7bc230c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
14 changes: 7 additions & 7 deletions DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@
/// Accepts a single value (e.g. autoconnect: ["router", "peer"]) which applies whatever the configured "mode" is,
/// or different values for router, peer or client mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }).
/// Each value is a list of: "peer", "router" and/or "client".
autoconnect: { router: [], peer: ["router", "peer"], client: ["router", "peer"] },
autoconnect: { router: [], peer: ["router", "peer"], client: ["router"] },
/// Whether or not to listen for scout messages on UDP multicast and reply to them.
listen: true,
},
/// The gossip scouting configuration.
/// The gossip scouting configuration. Note that instances in "client" mode do not participate in gossip.
gossip: {
/// Whether gossip scouting is enabled or not
enabled: true,
Expand All @@ -153,14 +153,14 @@
multihop: false,
/// Which type of Zenoh instances to send gossip messages to.
/// Accepts a single value (e.g. target: ["router", "peer"]) which applies whatever the configured "mode" is,
/// or different values for router, peer or client mode (e.g. target: { router: ["router", "peer"], peer: ["router"] }).
/// Each value is a list of: "peer", "router" and/or "client".
/// or different values for router or peer mode (e.g. target: { router: ["router", "peer"], peer: ["router"] }).
/// Each value is a list of "peer" and/or "router".
target: { router: ["router", "peer"], peer: ["router", "peer"]},
/// Which type of Zenoh instances to automatically establish sessions with upon discovery on gossip.
/// Accepts a single value (e.g. autoconnect: ["router", "peer"]) which applies whatever the configured "mode" is,
/// or different values for router, peer or client mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }).
/// Each value is a list of: "peer", "router" and/or "client".
autoconnect: { router: [], peer: ["router", "peer"], client: ["router", "peer"] },
/// or different values for router or peer mode (e.g. autoconnect: { router: [], peer: ["router", "peer"] }).
/// Each value is a list of: "peer" and/or "router".
autoconnect: { router: [], peer: ["router", "peer"] },
},
},

Expand Down
8 changes: 4 additions & 4 deletions commons/zenoh-config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ pub mod scouting {
&crate::WhatAmIMatcher::empty();
pub const peer: &crate::WhatAmIMatcher = // "router|peer"
&crate::WhatAmIMatcher::empty().router().peer();
pub const client: &crate::WhatAmIMatcher = // "router|peer"
&crate::WhatAmIMatcher::empty().router().peer();
pub const client: &crate::WhatAmIMatcher = // "router"
&crate::WhatAmIMatcher::empty().router();
mode_accessor!(crate::WhatAmIMatcher);
}
pub mod listen {
Expand All @@ -109,8 +109,8 @@ pub mod scouting {
&crate::WhatAmIMatcher::empty();
pub const peer: &crate::WhatAmIMatcher = // "router|peer"
&crate::WhatAmIMatcher::empty().router().peer();
pub const client: &crate::WhatAmIMatcher = // "router|peer"
&crate::WhatAmIMatcher::empty().router().peer();
pub const client: &crate::WhatAmIMatcher = // ""
&crate::WhatAmIMatcher::empty();
mode_accessor!(crate::WhatAmIMatcher);
}
}
Expand Down
7 changes: 4 additions & 3 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Runtime {
}

async fn start_client(&self) -> ZResult<()> {
let (peers, scouting, addr, ifaces, timeout, multicast_ttl) = {
let (peers, scouting, autoconnect, addr, ifaces, timeout, multicast_ttl) = {
let guard = &self.state.config.lock().0;
(
guard
Expand All @@ -137,6 +137,7 @@ impl Runtime {
.unwrap_or(&vec![])
.clone(),
unwrap_or_default!(guard.scouting().multicast().enabled()),
*unwrap_or_default!(guard.scouting().multicast().autoconnect().client()),
unwrap_or_default!(guard.scouting().multicast().address()),
unwrap_or_default!(guard.scouting().multicast().interface()),
std::time::Duration::from_millis(unwrap_or_default!(guard.scouting().timeout())),
Expand All @@ -146,7 +147,7 @@ impl Runtime {
match peers.len() {
0 => {
if scouting {
tracing::info!("Scouting for router ...");
tracing::info!("Scouting...");
let ifaces = Runtime::get_interfaces(&ifaces);
if ifaces.is_empty() {
bail!("Unable to find multicast interface!")
Expand All @@ -158,7 +159,7 @@ impl Runtime {
if sockets.is_empty() {
bail!("Unable to bind UDP port to any multicast interface!")
} else {
self.connect_first(&sockets, WhatAmI::Router.into(), &addr, timeout)
self.connect_first(&sockets, autoconnect, &addr, timeout)
.await
}
}
Expand Down

0 comments on commit 7bc230c

Please sign in to comment.