Skip to main content

forge_core/cluster/
mod.rs

1//! Cluster coordination and node management.
2//!
3//! Forge nodes discover each other via PostgreSQL without external service discovery.
4//! Nodes register in `forge_nodes`, send heartbeats, and are marked dead if stale.
5//!
6//! # Node Roles
7//!
8//! Each node can assume one or more roles:
9//!
10//! | Role | Responsibility |
11//! |------|----------------|
12//! | Gateway | HTTP/WebSocket endpoints |
13//! | Function | Query/mutation execution |
14//! | Worker | Background job processing |
15//! | Scheduler | Cron scheduling (singleton via advisory lock) |
16//!
17//! # Leader Election
18//!
19//! Singleton processes use PostgreSQL advisory locks. Only one node holds the
20//! lock at a time. If the leader crashes, PostgreSQL releases the lock and
21//! a standby node acquires it.
22//!
23//! # Key Types
24//!
25//! - [`NodeId`] - Unique node identifier (UUID)
26//! - [`NodeInfo`] - Node metadata (hostname, roles, capabilities)
27//! - [`NodeRole`] - Role enum (Gateway, Function, Worker, Scheduler)
28//! - [`LeaderRole`] - Singleton role requiring leader election
29
30mod node;
31mod roles;
32mod traits;
33
34pub use node::{NodeId, NodeInfo, NodeStatus, ParseNodeStatusError};
35pub use roles::{LeaderRole, NodeRole, ParseLeaderRoleError, ParseNodeRoleError};
36pub use traits::{ClusterInfo, LeaderInfo};