macula_membership_gossip (macula v0.14.3)

View Source

Gossip 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

gossip_state/0

-type gossip_state() ::
          #{updates =>
                #{binary() =>
                      {macula_membership_member:status(),
                       non_neg_integer(),
                       non_neg_integer(),
                       integer()}}}.

update/0

Functions

add_update(State, NodeId, Status, Incarnation)

Add a membership update to gossip. If a more recent update exists, it's replaced.

get_updates(_, MaxUpdates)

-spec get_updates(gossip_state(), pos_integer()) -> [update()].

Get updates to piggyback on messages. Returns most recent updates first, limited by max_updates.

mark_transmitted(State, NodeId)

-spec mark_transmitted(gossip_state(), binary()) -> gossip_state().

Mark an update as transmitted (increment transmit count).

merge_updates(State, ReceivedUpdates)

Merge received gossip updates into local state. Uses SWIM merge semantics (higher incarnation wins, etc.).

new()

-spec new() -> gossip_state().

Create a new gossip state.

prune(State, TargetTransmitCount)

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