View Source partisan_util (partisan v5.0.0-beta.13)

Link to this section Summary

Functions

Convert a list of elements into an N-ary tree. This conversion works by treating the list as an array-based tree where, for example in a binary 2-ary tree, a node at index i has children 2i and 2i+1. The conversion also supports a "cycles" mode where the array is logically wrapped around to ensure leaf nodes also have children by giving them backedges to other elements.
Tries to create a new connection to a node if required. If succesfull it store the new connection record in partisan_peer_connections.

Create a new connection to a node storing a new connection record in partisan_peer_connections.

Link to this section Types

-type channel() :: atom().
-type connect_opts() :: #{prune => boolean()}.
-type listen_addr() :: #{ip => inet:ip_address(), port => non_neg_integer()}.
-type node_spec() ::
    #{name => node(),
      listen_addrs => [listen_addr()],
      channels => [channel()],
      parallelism => non_neg_integer()}.

Link to this section Functions

Link to this function

build_tree(N, Nodes, Opts)

View Source
-spec build_tree(N :: integer(), Nodes :: [term()], Opts :: [term()]) -> orddict:orddict().
Convert a list of elements into an N-ary tree. This conversion works by treating the list as an array-based tree where, for example in a binary 2-ary tree, a node at index i has children 2i and 2i+1. The conversion also supports a "cycles" mode where the array is logically wrapped around to ensure leaf nodes also have children by giving them backedges to other elements.
Link to this function

maps_append(Key, Value, Map)

View Source
Link to this function

may_disconnect(NodeName)

View Source
-spec maybe_connect(Node :: node_spec()) -> ok.
Tries to create a new connection to a node if required. If succesfull it store the new connection record in partisan_peer_connections.
-spec maybe_connect(Node :: node_spec(), connect_opts()) -> ok | {ok, StaleSpecs :: [node_spec()]}.

Create a new connection to a node storing a new connection record in partisan_peer_connections.

Returns the tuple {ok, L :: [node_spec()]} where list L is the list of all invalid nodes specifications.

Aa specification is invalid if there is another specification for the same node for which we already have succesful connections. An invalid specification will exist when a node has crashed (without leaving the cluster) and later on returned with a different IP address i.e. a normal situation on cloud orchestration platforms. In this case the membership set (partisan_membership_set) will have two node specifications for the same node (with differing values for the listen_addrs property).