partisan_peer_connections (partisan v6.0.0)
View SourceSummary
Functions
Returns the channel name of the connection
Finds connection for a node.
Finds connection for a node.
Finds connection for a node and channel.
Finds connection for a node and channel.
Returns the number of connections for node Node.
Returns the nbr of connections for node Node and channel Channel.
Sends the *same* message to several peers, encoding it once.
Return a pid to use for message dispatch.
Return a pid to use for message dispatch.
Return a {ok, Pid} where Pid is the connection pid to use for message dispatch. If channel Channel is disconnected it falls back to a default channel connection if one exists. If no connections exist returns {error, disconnected}.
Returns a tuple {ok, Value}, where Value is an instance of info() associated with Node, or error if no info is associated with Node.
Creates a new connections table. The owner of the table is the calling process and the table is protected so only the owner can write to it.
Returns true is this node is connected to NodeOrName. If Node is this node, returns true.
Returns true is this node is connected to NodeOrName. If Node is this node, returns true.
Returns true is this node has all the requested connections (parallelism configuration parameter) for all the configured channels with node NodeOrSpec.
Returns a list of all nodes specifications connected to this node.
Returns a list of all nodes connected to this node through normal connections (that is, hidden nodes are not listed).
Returns the pids for all the active connection for a node.
Returns the pids for all the active connection for a node and channel.
Prune all occurrences of a connection pid returns the node where the pruned pid was found. Equivalent to prune(Arg, undefined).
Same as prune/1 but allows passing a Reason (e.g. the connection process' exit reason) that is added to the metadata of the resulting [partisan, connection, down] telemetry event.
Store a connection
Types
-type connection() :: #partisan_peer_connection{pid :: maybe_var(pid()), node :: maybe_var(node()), channel :: maybe_var(partisan:channel()), listen_addr :: maybe_var(partisan:listen_addr()) | listen_addr_spec(), timestamp :: maybe_var(non_neg_integer())}.
-type connections() :: [connection()].
-type info() :: #partisan_peer_info{node :: maybe_var(node()), node_spec :: maybe_var(partisan:node_spec()), connection_count :: maybe_var(non_neg_integer()), timestamp :: maybe_var(non_neg_integer())}.
-type maybe_var(T) :: T | var().
-type optional(T) :: T | undefined.
-type var() :: '_' | '$1' | '$2' | '$3'.
Functions
-spec channel(connection()) -> partisan:channel().
Returns the channel name of the connection
-spec connections() -> connections().
Finds connection for a node.
-spec connections(NodeOrSpec :: atom() | partisan:node_spec()) -> connections().
Finds connection for a node.
-spec connections(NodeOrSpec :: maybe_var(atom() | partisan:node_spec()), Channels :: maybe_var(partisan:channel() | [partisan:channel()])) -> connections() | no_return().
Finds connection for a node and channel.
-spec connections(NodeOrSpec :: maybe_var(atom() | partisan:node_spec()), Channels :: maybe_var(partisan:channel() | [partisan:channel()]), ListenAddr :: partisan:listen_addr()) -> connections() | no_return().
Finds connection for a node and channel.
-spec count() -> non_neg_integer().
-spec count(Arg :: partisan:node_spec() | node() | info()) -> non_neg_integer().
Returns the number of connections for node Node.
When passed a partisan:node_spec() as Arg it is equivalent to calling count/2 with a wildcard as a second argument i.e. '_'. However, when passed a node()` as `Arg is uses the more efficient ets` `lookup_element operation.
-spec count(NodeOrSpec :: maybe_var(partisan:node_spec() | node()), Channels :: maybe_var(partisan:channel() | [partisan:channel()])) -> non_neg_integer() | no_return().
Returns the nbr of connections for node Node and channel Channel.
-spec count(Node :: maybe_var(node() | partisan:node_spec()), Channels :: maybe_var(partisan:channel() | [partisan:channel()]), ListenAddr :: partisan:listen_addr()) -> Count :: non_neg_integer().
-spec dispatch(any()) -> ok | {error, disconnected | not_yet_connected}.
-spec dispatch_many(Peers :: [node()], ServerRef :: partisan:server_ref(), Message :: any(), Channel :: partisan:channel()) -> Deferred :: [node()].
Sends the *same* message to several peers, encoding it once.
A fan-out (plumtree's eager push to its peer set) otherwise encodes an identical payload once per peer, because each peer's send is an independent forward_message/4 call. The wire term is byte-identical for every peer — the destination is the group's registered name, which is the same atom on every node — so one encoding serves all of them.
Returns the peers this function did **not** handle. The caller must send to those by the ordinary per-peer path. A peer is deferred when it needs routing this function deliberately does not reimplement:
- the local node, which is a direct delivery rather than a send;
- a peer reachable over disterl while
connect_disterlis set, whichforward_message/4short-circuits witherlang:send/3; - a peer with no connection on
Channel, which has its own not-yet-connected / disconnected handling; - every peer, when
disable_fast_forwardis set — that option exists to force traffic through the peer service manager.
Message must already be in its final wire form, i.e. whatever forward_message/4 would have passed to dispatch/1 ($gen_cast-wrapped and padded as applicable).
-spec dispatch_pid(node() | partisan:node_spec()) -> {ok, pid()} | {error, disconnected | not_yet_connected | notalive}.
Return a pid to use for message dispatch.
-spec dispatch_pid(Node :: node() | partisan:node_spec(), Channel :: partisan:channel()) -> {ok, pid()} | {error, disconnected | not_yet_connected | notalive} | no_return().
Return a pid to use for message dispatch.
-spec dispatch_pid(Node :: node() | partisan:node_spec(), Channel :: partisan:channel(), PartitionKey :: optional(any())) -> {ok, pid()} | {error, disconnected | not_yet_connected | notalive} | no_return().
Return a {ok, Pid} where Pid is the connection pid to use for message dispatch. If channel Channel is disconnected it falls back to a default channel connection if one exists. If no connections exist returns {error, disconnected}.
-spec erase(pid() | node() | partisan:node_spec()) -> ok.
-spec fold(Fun :: fun((partisan:node_spec(), connections(), Acc1 :: any()) -> Acc2 :: any()), AccIn :: any()) -> AccOut :: any().
-spec foreach(Fun :: fun((info(), connections()) -> ok)) -> ok.
-spec info(NodeOrSpec :: partisan:node_spec() | node()) -> {ok, info()} | error.
Returns a tuple {ok, Value}, where Value is an instance of info() associated with Node, or error if no info is associated with Node.
-spec init() -> ok.
Creates a new connections table. The owner of the table is the calling process and the table is protected so only the owner can write to it.
-spec is_connected(NodeOrSpec :: partisan:node_spec() | node()) -> boolean().
Returns true is this node is connected to NodeOrName. If Node is this node, returns true.
-spec is_connected(NodeOrSpec :: partisan:node_spec() | node(), Channels :: maybe_var(partisan:channel() | [partisan:channel()])) -> boolean() | no_return().
Returns true is this node is connected to NodeOrName. If Node is this node, returns true.
-spec is_fully_connected(Peer :: partisan:node_spec() | node()) -> boolean().
Returns true is this node has all the requested connections (parallelism configuration parameter) for all the configured channels with node NodeOrSpec.
-spec kill(node()) -> ok.
-spec kill_all() -> ok.
-spec listen_addr(connection()) -> partisan:listen_addr() | no_return().
-spec node(info() | connection()) -> node() | no_return().
-spec node_spec(info() | connection()) -> partisan:node_spec() | no_return().
Returns a list of all nodes specifications connected to this node.
-spec nodes() -> [node()].
Returns a list of all nodes connected to this node through normal connections (that is, hidden nodes are not listed).
-spec pid(connection()) -> pid().
-spec processes(NodeOrSpec :: atom() | partisan:node_spec()) -> [pid()].
Returns the pids for all the active connection for a node.
-spec processes(NodeOrSpec :: node() | partisan:node_spec(), Channel :: maybe_var(partisan:channel())) -> [pid()].
Returns the pids for all the active connection for a node and channel.
-spec prune(pid() | node() | partisan:node_spec()) -> {info(), connections()} | no_return().
Prune all occurrences of a connection pid returns the node where the pruned pid was found. Equivalent to prune(Arg, undefined).
-spec prune(pid() | node() | partisan:node_spec(), Reason :: term()) -> {info(), connections()} | no_return().
Same as prune/1 but allows passing a Reason (e.g. the connection process' exit reason) that is added to the metadata of the resulting [partisan, connection, down] telemetry event.
-spec store(Node :: partisan:node_spec(), Pid :: pid(), Channel :: partisan:channel(), LitenAddr :: partisan:listen_addr()) -> ok | no_return().
Store a connection
-spec timestamp(info() | connection()) -> non_neg_integer() | no_return().