View Source partisan_membership_set (partisan v5.0.0-beta.21)
This module represents the cluster membership view for this node.
When a node joins the cluster it is added to the set. Conversely when a node leaves the cluster it is removed from the set. A node that crashes or gets disconnected will remain in the set so that Partisan can try to re-connect with the node when it restarts or becomes reachable again.
implementation
Implementation
The set is implemented as a CRDT set of partisan:node_spec/0 objects. More specifically a state_orset.
Notice that because the set stores partisan:node_spec/0 objects and not node(), the set can have multiple partisan:node_spec/0 objects for the same node.
This can occur when the set contains one or more stale specifications.
stale-specifications
Stale Specifications
A stale specification exists due to the following reasons:
- A node crashes (without leaving the cluster) and returns bearing different IP Addresses (the value of the node specification's
listen_addrsproperty). This is common in cloud orchestration scenarios where instances have dynamic IP addresses. - A node crashes (without leaving the cluster) and returns bearing different values for the node specification properties
channelsand/orparallelism. For example, this can happen in the case the Partisan configuration has changed when using a rolling update strategy i.e. a gradual update process that allows you to update a cluster one node at a time to minimise downtime.
Link to this section Summary
Functions
{Joiners, Leavers} where Joiners is the list of node specifications that are elements of List but are not in the membership set, and Leavers are the node specifications for the current members that are not elements in List.Link to this section Types
-opaque t()
Link to this section Functions
-spec add(partisan:node_spec(), Actor :: partisan:actor(), t()) -> t().
-spec compare([partisan:node_spec()], t()) -> {Joiners :: [partisan:node_spec()], Leavers :: [partisan:node_spec()]}.
{Joiners, Leavers} where Joiners is the list of node specifications that are elements of List but are not in the membership set, and Leavers are the node specifications for the current members that are not elements in List.
-spec decode(binary()) -> t().
-spec encode(t()) -> binary().
-spec new() -> t().
-spec remove(partisan:node_spec(), Actor :: partisan:actor(), t()) -> t().
-spec to_list(t()) -> [partisan:node_spec()].
-spec to_peer_list(t()) -> [partisan:node_spec()].