Skip to content

Commit

Permalink
Merge branch 'main' into dev/expression_caching
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Jan 7, 2025
2 parents c4bd719 + e9298c6 commit c5a18c5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion DEFAULT_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
/// When set to true a router will forward data between two peers
/// directly connected to it if it detects that those peers are not
/// connected to each other.
/// The failover brokering only works if gossip discovery is enabled.
/// The failover brokering only works if gossip discovery is enabled
/// and peers are configured with gossip target "router".
peers_failover_brokering: true,
},
/// The routing strategy to use in peers and it's configuration.
Expand Down
4 changes: 3 additions & 1 deletion zenoh/src/net/routing/hat/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ impl HatTables {
pub(crate) struct HatCode {}

impl HatBaseTrait for HatCode {
fn init(&self, _tables: &mut Tables, _runtime: Runtime) {}
fn init(&self, _tables: &mut Tables, _runtime: Runtime) -> ZResult<()> {
Ok(())
}

fn new_tables(&self, _router_peers_failover_brokering: bool) -> Box<dyn Any + Send + Sync> {
Box::new(HatTables::new())
Expand Down
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/hat/linkstate_peer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,16 @@ impl HatTables {
pub(crate) struct HatCode {}

impl HatBaseTrait for HatCode {
fn init(&self, tables: &mut Tables, runtime: Runtime) {
fn init(&self, tables: &mut Tables, runtime: Runtime) -> ZResult<()> {
let config_guard = runtime.config().lock();
let config = &config_guard.0;
let whatami = tables.whatami;
let gossip = unwrap_or_default!(config.scouting().gossip().enabled());
let gossip_multihop = unwrap_or_default!(config.scouting().gossip().multihop());
let gossip_target = *unwrap_or_default!(config.scouting().gossip().target().get(whatami));
if gossip_target.matches(WhatAmI::Client) {
bail!("\"client\" is not allowed as gossip target")
}
let autoconnect = if gossip {
*unwrap_or_default!(config.scouting().gossip().autoconnect().get(whatami))
} else {
Expand All @@ -209,6 +212,7 @@ impl HatBaseTrait for HatCode {
gossip_target,
autoconnect,
));
Ok(())
}

fn new_tables(&self, _router_peers_failover_brokering: bool) -> Box<dyn Any + Send + Sync> {
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/hat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(crate) trait HatTrait:
}

pub(crate) trait HatBaseTrait {
fn init(&self, tables: &mut Tables, runtime: Runtime);
fn init(&self, tables: &mut Tables, runtime: Runtime) -> ZResult<()>;

fn new_tables(&self, router_peers_failover_brokering: bool) -> Box<dyn Any + Send + Sync>;

Expand Down
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/hat/p2p_peer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ impl HatTables {
pub(crate) struct HatCode {}

impl HatBaseTrait for HatCode {
fn init(&self, tables: &mut Tables, runtime: Runtime) {
fn init(&self, tables: &mut Tables, runtime: Runtime) -> ZResult<()> {
let config_guard = runtime.config().lock();
let config = &config_guard.0;
let whatami = tables.whatami;
let gossip = unwrap_or_default!(config.scouting().gossip().enabled());
let gossip_multihop = unwrap_or_default!(config.scouting().gossip().multihop());
let gossip_target = *unwrap_or_default!(config.scouting().gossip().target().get(whatami));
if gossip_target.matches(WhatAmI::Client) {
bail!("\"client\" is not allowed as gossip target")
}
let autoconnect = if gossip {
*unwrap_or_default!(config.scouting().gossip().autoconnect().get(whatami))
} else {
Expand All @@ -139,6 +142,7 @@ impl HatBaseTrait for HatCode {
wait_declares,
));
}
Ok(())
}

fn new_tables(&self, _router_peers_failover_brokering: bool) -> Box<dyn Any + Send + Sync> {
Expand Down
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/hat/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,16 @@ impl HatTables {
pub(crate) struct HatCode {}

impl HatBaseTrait for HatCode {
fn init(&self, tables: &mut Tables, runtime: Runtime) {
fn init(&self, tables: &mut Tables, runtime: Runtime) -> ZResult<()> {
let config_guard = runtime.config().lock();
let config = &config_guard.0;
let whatami = tables.whatami;
let gossip = unwrap_or_default!(config.scouting().gossip().enabled());
let gossip_multihop = unwrap_or_default!(config.scouting().gossip().multihop());
let gossip_target = *unwrap_or_default!(config.scouting().gossip().target().get(whatami));
if gossip_target.matches(WhatAmI::Client) {
bail!("\"client\" is not allowed as gossip target")
}
let autoconnect = if gossip {
*unwrap_or_default!(config.scouting().gossip().autoconnect().get(whatami))
} else {
Expand Down Expand Up @@ -358,6 +361,7 @@ impl HatBaseTrait for HatCode {
hat!(tables).linkstatepeers_net.as_ref().unwrap(),
);
}
Ok(())
}

fn new_tables(&self, router_peers_failover_brokering: bool) -> Box<dyn Any + Send + Sync> {
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Router {
})
}

pub fn init_link_state(&mut self, runtime: Runtime) {
pub fn init_link_state(&mut self, runtime: Runtime) -> ZResult<()> {
let ctrl_lock = zlock!(self.tables.ctrl_lock);
let mut tables = zwrite!(self.tables.tables);
tables.runtime = Some(Runtime::downgrade(&runtime));
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl RuntimeBuilder {
}),
};
*handler.runtime.write().unwrap() = Runtime::downgrade(&runtime);
get_mut_unchecked(&mut runtime.state.router.clone()).init_link_state(runtime.clone());
get_mut_unchecked(&mut runtime.state.router.clone()).init_link_state(runtime.clone())?;

// Admin space
if start_admin_space {
Expand Down

0 comments on commit c5a18c5

Please sign in to comment.