Skip to content

Commit

Permalink
fix: missing register service (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm authored Nov 28, 2023
1 parent 115dd25 commit 4799a77
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/core/router/src/force_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::{RouteAction, RouterTable};
pub struct ForceLocalRouter();

impl RouterTable for ForceLocalRouter {
fn register_service(&self, _service_id: u8) {}

fn path_to_node(&self, _dest: NodeId) -> RouteAction {
RouteAction::Local
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/router/src/force_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::{RouteAction, RouterTable};
pub struct ForceNodeRouter(pub ConnId, pub NodeId);

impl RouterTable for ForceNodeRouter {
fn register_service(&self, _service_id: u8) {}

fn path_to_node(&self, _dest: NodeId) -> RouteAction {
RouteAction::Next(self.0, self.1)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ impl RouteAction {

#[cfg_attr(any(test, feature = "mock"), automock)]
pub trait RouterTable: Send + Sync {
/// Register service
fn register_service(&self, service_id: u8);
/// Determine the next action for the given destination node
fn path_to_node(&self, dest: NodeId) -> RouteAction;
/// Determine the next action for the given key
Expand Down
1 change: 1 addition & 0 deletions packages/network/src/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ where

let mut new_behaviours = vec![];
for behaviour in conf.behaviors {
conf.router.register_service(behaviour.service_id());
let awake = BehaviourAwake {
service_id: behaviour.service_id(),
bus: bus.clone(),
Expand Down
8 changes: 4 additions & 4 deletions packages/routers/layers_spread_router/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ impl SharedRouter {
self.router.read().size()
}

pub fn register_service(&self, service_id: u8) {
self.router.write().register_service(service_id)
}

pub fn service_next(&self, service_id: u8, excepts: &[NodeId]) -> Option<ServiceDestination> {
self.router.read().service_next(service_id, excepts)
}
Expand Down Expand Up @@ -74,6 +70,10 @@ impl SharedRouter {
}

impl RouterTable for SharedRouter {
fn register_service(&self, service_id: u8) {
self.router.write().register_service(service_id)
}

fn path_to_node(&self, dest: NodeId) -> RouteAction {
if self.node_id == dest {
return RouteAction::Local;
Expand Down

0 comments on commit 4799a77

Please sign in to comment.