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
-spec build_tree(N :: integer(), Nodes :: [term()], Opts :: [term()]) -> orddict:orddict().
-spec maybe_connect(Node :: node_spec()) -> ok.
-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.
partisan_membership_set
) will have two node specifications for the same node (with differing values for the listen_addrs
property).