distribute/cluster/gossip
Types
A gossip entry representing a node’s state.
pub type GossipEntry {
GossipEntry(
node: String,
status: NodeStatus,
incarnation: Int,
timestamp: Int,
)
}
Constructors
-
GossipEntry( node: String, status: NodeStatus, incarnation: Int, timestamp: Int, )
Gossip message containing a list of entries.
pub type GossipMessage {
GossipMessage(entries: List(GossipEntry))
}
Constructors
-
GossipMessage(entries: List(GossipEntry))
Represents the status of a node in the cluster.
pub type NodeStatus {
Alive
Suspect
Dead
}
Constructors
-
Alive -
Suspect -
Dead
Values
pub fn local_view() -> List(GossipEntry)
Get the local gossip view as a list of entries.
pub fn merge_single(entry: GossipEntry) -> Nil
Merge a single entry into the local view. Uses the rule: higher incarnation wins; on tie, alive > suspect > dead.
pub fn pick_random_peers(
nodes: List(String),
count: Int,
) -> List(String)
Pick random peers from a list of nodes.
pub fn receive_and_merge(entries: List(GossipEntry)) -> Nil
Receive and merge gossip from a peer.
pub fn send_to(node: String, entries: List(GossipEntry)) -> Nil
Send gossip to a specific node.