Skip to main content

ClusterMode

Enum ClusterMode 

Source
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

§node_id: u64

This node’s id (must be unique within the cluster).

§peers: Vec<RaftPeer>

Peer addresses (raft RPC ports). The daemon’s own entry must be present.

§

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

§node_id: u64

This node’s id (must be unique within the cluster).

§peers: Vec<StaticPeer>

All cluster peers including self.

§heartbeat_interval: Duration

Heartbeat probe interval. Default 5s.

§failure_threshold: Duration

Time after which a peer with no heartbeat is Unreachable. Default 15s (3x interval).

§

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: WorkerTierRole

What 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: SocketAddr

Server-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_min_ttl: Duration

Shared: minimum heartbeat TTL (default 10s).

§heartbeat_max_ttl: Duration

Shared: maximum heartbeat TTL (default 10min).

§heartbeat_grace: Duration

Shared: grace period beyond TTL before a worker’s lease is considered expired. Default 10s.

§max_heartbeats_per_second: u32

Server-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).

§failover_heartbeat_ttl: Duration

Server-only: TTL applied immediately after a leader election so workers don’t all expire while the new leader is bootstrapping its FSM. Default 5min.

§labels: HashMap<String, String>

Free-form node labels (placement, selector matching, etc.).

Implementations§

Source§

impl ClusterMode

Source

pub fn adaptive_ttl_config(&self) -> Option<AdaptiveTtlConfig>

Extract an AdaptiveTtlConfig from a WorkerTier variant. Returns None for other modes.

Source

pub fn is_worker_tier_server(&self) -> bool

Convenience: is this a worker-tier server-role config?

Source

pub fn is_worker_tier_worker(&self) -> bool

Convenience: is this a worker-tier worker-role config?

Trait Implementations§

Source§

impl Clone for ClusterMode

Source§

fn clone(&self) -> ClusterMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClusterMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClusterMode

Source§

fn default() -> ClusterMode

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ClusterMode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ClusterMode

Source§

impl PartialEq for ClusterMode

Source§

fn eq(&self, other: &ClusterMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ClusterMode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ClusterMode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromBase64 for T
where T: for<'de> Deserialize<'de>,

Source§

fn from_base64<Input>(raw: &Input) -> Result<T, Error>
where Input: AsRef<[u8]> + ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<C> SignWithKey<String> for C
where C: ToBase64,

Source§

impl<T> ToBase64 for T
where T: Serialize,

Source§

fn to_base64(&self) -> Result<Cow<'_, str>, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more