Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing register service #85

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
pub struct ForceLocalRouter();

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

Check warning on line 10 in packages/core/router/src/force_local.rs

View check run for this annotation

Codecov / codecov/patch

packages/core/router/src/force_local.rs#L10

Added line #L10 was not covered by tests

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 @@
pub struct ForceNodeRouter(pub ConnId, pub NodeId);

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

Check warning on line 10 in packages/core/router/src/force_node.rs

View check run for this annotation

Codecov / codecov/patch

packages/core/router/src/force_node.rs#L10

Added line #L10 was not covered by tests

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
Loading