macula_membership_gossip (macula v0.20.5)
View SourceGossip dissemination for SWIM protocol. Tracks membership updates and provides them for piggybacking. Uses exponential decay: log(N) messages per update.
Summary
Functions
Add a membership update to gossip. If a more recent update exists, it's replaced.
Get updates to piggyback on messages. Returns most recent updates first, limited by max_updates.
Mark an update as transmitted (increment transmit count).
Merge received gossip updates into local state. Uses SWIM merge semantics (higher incarnation wins, etc.).
Create a new gossip state.
Prune updates that have been transmitted enough times. Target is typically log(N) where N is cluster size.
Types
-type gossip_state() :: #{updates => #{binary() => {macula_membership_member:status(), non_neg_integer(), non_neg_integer(), integer()}}}.
-type update() :: {binary(), macula_membership_member:status(), non_neg_integer(), non_neg_integer()}.
Functions
-spec add_update(gossip_state(), binary(), macula_membership_member:status(), non_neg_integer()) -> gossip_state().
Add a membership update to gossip. If a more recent update exists, it's replaced.
-spec get_updates(gossip_state(), pos_integer()) -> [update()].
Get updates to piggyback on messages. Returns most recent updates first, limited by max_updates.
-spec mark_transmitted(gossip_state(), binary()) -> gossip_state().
Mark an update as transmitted (increment transmit count).
-spec merge_updates(gossip_state(), [{binary(), macula_membership_member:status(), non_neg_integer()}]) -> gossip_state().
Merge received gossip updates into local state. Uses SWIM merge semantics (higher incarnation wins, etc.).
-spec new() -> gossip_state().
Create a new gossip state.
-spec prune(gossip_state(), non_neg_integer()) -> gossip_state().
Prune updates that have been transmitted enough times. Target is typically log(N) where N is cluster size.