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

Function wire_state

nodedb/src/bootstrap/state_wiring.rs:30–279  ·  view source on GitHub ↗

Wire all optional subsystems into SharedState after `SharedState::open`. This includes: startup gate, cluster handles, JWKS, cold storage, snapshot storage, quarantine storage, memory governor, backup KEK, OTLP exporter, gateway, and bitemporal retention registry.

(
    shared: &mut Arc<SharedState>,
    config: &ServerConfig,
    startup_gate: &Arc<StartupGate>,
    cluster_handle: Option<&ClusterHandle>,
    components: SharedStateComponents,
    root_span: &

Source from the content-addressed store, hash-verified

28/// storage, quarantine storage, memory governor, backup KEK, OTLP exporter,
29/// gateway, and bitemporal retention registry.
30pub fn wire_state(
31 shared: &mut Arc<SharedState>,
32 config: &ServerConfig,
33 startup_gate: &Arc<StartupGate>,
34 cluster_handle: Option<&ClusterHandle>,
35 components: SharedStateComponents,
36 root_span: &tracing::Span,
37) -> anyhow::Result<()> {
38 let SharedStateComponents {
39 quarantine_registry,
40 governor,
41 system_metrics,
42 array_catalog,
43 maintenance_budget,
44 } = components;
45 // Install startup gate.
46 if let Some(state) = Arc::get_mut(shared) {
47 state.startup = Arc::clone(startup_gate);
48 }
49
50 // Replay surrogate WAL records.
51 // Note: wal_records are not passed here — caller must handle surrogate replay
52 // before calling this function (it needs the catalog opened by SharedState::open).
53
54 // Install quarantine registry.
55 if let Some(state) = Arc::get_mut(shared) {
56 state.quarantine_registry = Arc::clone(&quarantine_registry);
57 }
58
59 // Wire cluster handles.
60 if let Some(handle) = cluster_handle
61 && let Some(state) = Arc::get_mut(shared)
62 {
63 state.node_id = handle.node_id;
64 state.cluster_topology = Some(Arc::clone(&handle.topology));
65 state.cluster_routing = Some(Arc::clone(&handle.routing));
66 state.cluster_transport = Some(Arc::clone(&handle.transport));
67 state.metadata_cache = Arc::clone(&handle.metadata_cache);
68 state.group_watchers = Arc::clone(&handle.group_watchers);
69 root_span.record("node_id", handle.node_id);
70 }
71
72 // Initialise JWKS registry.
73 if let Some(ref jwt_config) = config.auth.jwt
74 && !jwt_config.providers.is_empty()
75 && let Some(state) = Arc::get_mut(shared)
76 {
77 let registry = tokio::runtime::Handle::current().block_on(
78 crate::control::security::jwks::registry::JwksRegistry::init(jwt_config.clone()),
79 );
80 state.jwks_registry = Some(Arc::new(registry));
81 info!(
82 "JWKS registry initialised with {} providers",
83 jwt_config.providers.len()
84 );
85 }
86
87 // Initialise cold storage (L2 tiering).

Callers 1

mainFunction · 0.85

Calls 15

currentFunction · 0.85
build_snapshot_storeFunction · 0.85
build_quarantine_storeFunction · 0.85
all_entriesMethod · 0.80
readFunction · 0.50
recordMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected