Initialize the cluster: create transport, open catalog, bootstrap/join/restart. Returns the cluster handle; the caller must then call [`super::start_raft::start_raft`] after `SharedState` is constructed so the applier has the dispatcher / WAL it needs.
(
config: &ClusterSettings,
data_dir: &std::path::Path,
transport_tuning: &ClusterTransportTuning,
)
| 19 | /// [`super::start_raft::start_raft`] after `SharedState` is constructed |
| 20 | /// so the applier has the dispatcher / WAL it needs. |
| 21 | pub async fn init_cluster( |
| 22 | config: &ClusterSettings, |
| 23 | data_dir: &std::path::Path, |
| 24 | transport_tuning: &ClusterTransportTuning, |
| 25 | ) -> crate::Result<ClusterHandle> { |
| 26 | // 1a. Resolve TLS credentials (mandatory mTLS unless explicitly opted out). |
| 27 | let credentials = crate::control::cluster::tls::resolve_credentials(config, data_dir)?; |
| 28 | |
| 29 | // 1b. Create QUIC transport, configured from ClusterTransportTuning. |
| 30 | let transport = Arc::new( |
| 31 | nodedb_cluster::NexarTransport::with_tuning( |
| 32 | config.node_id, |
| 33 | config.listen, |
| 34 | transport_tuning, |
| 35 | credentials, |
| 36 | ) |
| 37 | .map_err(|e| crate::Error::Config { |
| 38 | detail: format!("cluster transport: {e}"), |
| 39 | })?, |
| 40 | ); |
| 41 | |
| 42 | info!( |
| 43 | node_id = config.node_id, |
| 44 | addr = %transport.local_addr(), |
| 45 | "cluster QUIC transport bound" |
| 46 | ); |
| 47 | |
| 48 | init_cluster_with_transport(config, transport, data_dir, transport_tuning).await |
| 49 | } |
| 50 | |
| 51 | /// Initialize the cluster using a pre-bound QUIC transport. |
| 52 | /// |
no test coverage detected