pub enum ClusterMode {
SingleNode,
Raft {
node_id: u64,
peers: Vec<RaftPeer>,
},
Static {
node_id: u64,
peers: Vec<StaticPeer>,
heartbeat_interval: Duration,
failure_threshold: Duration,
},
WorkerTier {Show 14 fields
role: WorkerTierRole,
node_id: Option<u64>,
peers: Vec<RaftPeer>,
worker_grpc_addr: SocketAddr,
servers: Vec<String>,
token_file: Option<String>,
identity_dir: Option<String>,
worker_ca_dir: Option<String>,
heartbeat_min_ttl: Duration,
heartbeat_max_ttl: Duration,
heartbeat_grace: Duration,
max_heartbeats_per_second: u32,
failover_heartbeat_ttl: Duration,
labels: HashMap<String, String>,
},
}Expand description
How the daemon participates in (or doesn’t) cluster membership.
The WorkerTier variant is intentionally large (~285 bytes) because it
carries the full server-role + worker-role config inline. ClusterMode
is parsed once at daemon startup and lives in an Arc<DaemonConfig> for
the process lifetime, so the size delta is irrelevant in practice — and
boxing it would force every caller of is_worker_tier_server() /
adaptive_ttl_config() through an extra indirection for no win.
Variants§
SingleNode
Single-node daemon. No peers, no consensus. is_leader() is always
true. Suitable for development and single-host deployments.
Raft
openraft-backed consensus across the configured peers. This is the existing production mode for multi-node deployments.
Fields
Static
Static-membership cluster: config-driven peer list, deterministic
leader (lowest healthy node id), HTTP heartbeats for liveness.
No consensus log — concurrent writers may race; the per-service
scale semaphore in ServiceManager is the primary mitigation.
Fields
peers: Vec<StaticPeer>All cluster peers including self.
WorkerTier
Nomad-style worker tier: 3–7 control-plane nodes run Raft consensus; up to ~10,000 worker nodes join as gRPC clients with adaptive-TTL heartbeats and never enter consensus.
Workers are issued mTLS leaf certs by the cluster’s worker CA during
Register. Heartbeat cadence scales with cluster size — every
StatusAck carries the next TTL computed from
clamp(N_workers / max_heartbeats_per_second, min_ttl, max_ttl).
Fields
role: WorkerTierRoleWhat role THIS node plays.
node_id: Option<u64>Server-only: this node’s id within the raft control plane. Required when role == Server; ignored on workers (assigned by leader during Register).
peers: Vec<RaftPeer>Server-only: the raft control-plane peer list (3-7 nodes). Required when role == Server.
worker_grpc_addr: SocketAddrServer-only: address to bind the worker-facing gRPC server.
Default 0.0.0.0:3670 (the API server uses 3669; gRPC takes 3670).
servers: Vec<String>Worker-only: control-plane gRPC endpoints to try (round-robin fallback). Required when role == Worker.
token_file: Option<String>Worker-only: path to the bootstrap token file (single line,
URL-safe-base64 of a WorkerBootstrapToken).
identity_dir: Option<String>Worker-only: directory to persist mTLS identity (cert.pem, key.pem,
ca.pem). Defaults to <data_dir>/worker/identity/ set by
ZLayerDirs.
worker_ca_dir: Option<String>Server-only: worker CA storage directory. Defaults to
<data_dir>/cluster/ (same as the existing cluster CA + signer).
heartbeat_grace: DurationShared: grace period beyond TTL before a worker’s lease is considered expired. Default 10s.
max_heartbeats_per_second: u32Server-only: cluster-wide cap on heartbeats/second the leader is willing to absorb. The leader hands every worker a TTL such that total HB rate ≤ this. Default 50 (Nomad’s default).
Implementations§
Source§impl ClusterMode
impl ClusterMode
Sourcepub fn adaptive_ttl_config(&self) -> Option<AdaptiveTtlConfig>
pub fn adaptive_ttl_config(&self) -> Option<AdaptiveTtlConfig>
Extract an AdaptiveTtlConfig from a WorkerTier variant. Returns
None for other modes.
Sourcepub fn is_worker_tier_server(&self) -> bool
pub fn is_worker_tier_server(&self) -> bool
Convenience: is this a worker-tier server-role config?
Sourcepub fn is_worker_tier_worker(&self) -> bool
pub fn is_worker_tier_worker(&self) -> bool
Convenience: is this a worker-tier worker-role config?
Trait Implementations§
Source§impl Clone for ClusterMode
impl Clone for ClusterMode
Source§fn clone(&self) -> ClusterMode
fn clone(&self) -> ClusterMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClusterMode
impl Debug for ClusterMode
Source§impl Default for ClusterMode
impl Default for ClusterMode
Source§fn default() -> ClusterMode
fn default() -> ClusterMode
Source§impl<'de> Deserialize<'de> for ClusterMode
impl<'de> Deserialize<'de> for ClusterMode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ClusterMode
Source§impl PartialEq for ClusterMode
impl PartialEq for ClusterMode
Source§fn eq(&self, other: &ClusterMode) -> bool
fn eq(&self, other: &ClusterMode) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ClusterMode
impl Serialize for ClusterMode
impl StructuralPartialEq for ClusterMode
Auto Trait Implementations§
impl Freeze for ClusterMode
impl RefUnwindSafe for ClusterMode
impl Send for ClusterMode
impl Sync for ClusterMode
impl Unpin for ClusterMode
impl UnsafeUnpin for ClusterMode
impl UnwindSafe for ClusterMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.