MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / register_default_subsystems

Function register_default_subsystems

nodedb-cluster/src/bootstrap/start.rs:67–112  ·  view source on GitHub ↗

Register the default set of cluster subsystems into `registry`. Called by [`start_cluster`] after the initial cluster state is resolved and the `BootstrapCtx` is assembled. The four subsystems are: 1. `SwimSubsystem` (root, `deps = []`) — failure detector with `RoutingLivenessHook` attached before the UDP socket opens. `RoutingLivenessHook` is NOT its own subsystem; it is wired inside `SwimSubsy

(
    registry: &mut SubsystemRegistry,
    config: &ClusterConfig,
    ctx: &BootstrapCtx,
    executor: Arc<MigrationExecutor>,
)

Source from the content-addressed store, hash-verified

65/// registered as a top-level subsystem because it is sync/cheap and runs
66/// directly on the SWIM detector event loop, not as a separate task.
67pub fn register_default_subsystems(
68 registry: &mut SubsystemRegistry,
69 config: &ClusterConfig,
70 ctx: &BootstrapCtx,
71 executor: Arc<MigrationExecutor>,
72) -> crate::error::Result<()> {
73 let swim_cfg = SwimSubsystemConfig {
74 swim: crate::swim::config::SwimConfig::default(),
75 local_id: NodeId::try_new(config.node_id.to_string()).map_err(|e| {
76 crate::error::ClusterError::Config {
77 detail: format!("node_id is not a valid ID: {e}"),
78 }
79 })?,
80 // Use the explicit SWIM UDP addr if set; otherwise let the OS
81 // pick an ephemeral port by binding to port 0 on the listen addr.
82 swim_addr: config.swim_udp_addr.unwrap_or_else(|| {
83 let mut a = config.listen_addr;
84 a.set_port(0);
85 a
86 }),
87 seeds: config.seed_nodes.clone(),
88 };
89
90 registry.register(Arc::new(SwimSubsystem::new(
91 swim_cfg,
92 Arc::clone(&ctx.routing),
93 Arc::clone(&ctx.topology),
94 vec![],
95 )));
96
97 registry.register(Arc::new(ReachabilitySubsystem::new(
98 ReachabilityDriverConfig::default(),
99 )));
100
101 registry.register(Arc::new(DecommissionSubsystem::new(
102 ctx.transport.node_id(),
103 Duration::from_secs(5),
104 )));
105
106 registry.register(Arc::new(RebalancerSubsystem::new(
107 RebalancerLoopConfig::default(),
108 executor,
109 )));
110
111 Ok(())
112}
113
114/// Start the cluster state machine — bootstrap, join, or restart.
115///

Callers 1

start_cluster_subsystemsFunction · 0.85

Calls 4

to_stringMethod · 0.80
cloneMethod · 0.45
registerMethod · 0.45
node_idMethod · 0.45

Tested by

no test coverage detected