View Source partisan_membership_set (partisan v5.0.0-rc.8)

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

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

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_addrs property). 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 channels and/or parallelism. 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.

Summary

Functions

Returns the tuple {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.
Returns a list of node specifications but omitting the specification for the local node. No sorting is applied, so the sorting is undefined.

Types

-opaque t()

Functions

Link to this function

add(NodeSpec, Actor, T0)

View Source
-spec add(partisan:node_spec(), Actor :: partisan:actor(), t()) -> t().
-spec compare([partisan:node_spec()], t()) ->
           {Joiners :: [partisan:node_spec()], Leavers :: [partisan:node_spec()]}.
Returns the tuple {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 equal(t(), t()) -> boolean().
-spec merge(t(), t()) -> t().
-spec new() -> t().
Link to this function

remove(NodeSpec, Actor, T)

View Source
-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()].
Returns a list of node specifications but omitting the specification for the local node. No sorting is applied, so the sorting is undefined.