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>,
)
| 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. |
| 67 | pub 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 | /// |
no test coverage detected