Skip to main content

Module cluster

Module cluster 

Source
Expand description

Cluster coordination and node management.

Forge nodes discover each other via PostgreSQL without external service discovery. Nodes register in forge_nodes, send heartbeats, and are marked dead if stale.

§Node Roles

Each node can assume one or more roles:

RoleResponsibility
GatewayHTTP/WebSocket endpoints
FunctionQuery/mutation execution
WorkerBackground job processing
SchedulerCron scheduling (singleton via advisory lock)

§Leader Election

Singleton processes use PostgreSQL advisory locks. Only one node holds the lock at a time. If the leader crashes, PostgreSQL releases the lock and a standby node acquires it.

§Key Types

  • NodeId - Unique node identifier (UUID)
  • NodeInfo - Node metadata (hostname, roles, capabilities)
  • NodeRole - Role enum (Gateway, Function, Worker, Scheduler)
  • LeaderRole - Singleton role requiring leader election

Structs§

ClusterInfo
Information about the cluster.
LeaderInfo
Leadership information for a role.
NodeId
Unique node identifier.
NodeInfo
Information about a node in the cluster.
ParseLeaderRoleError
ParseNodeRoleError
ParseNodeStatusError

Enums§

LeaderRole
Leader role for coordinated operations.
NodeRole
Node role in the cluster.
NodeStatus
Node status in the cluster.