View Source partisan (partisan v5.0.0-beta.14)

Link to this section Summary

Functions

Broadcasts a message originating from this node.

Cast message to a remote ref
Cast message to registered process on the remote side.
Cast message to registered process on the remote side.
Returns a channel with name Name. Fails if a channel named Name doesn't exist.
Forward message to registered process on the remote side.
Forward message to registered process on the remote side.
Forward message to registered process on the remote side.
Returns true if the local node is alive (that is, if the node can be part of a distributed system), otherwise false.
Returns the name of the local node.
Returns the name of the local node.
Returns the name of the local node.
Returns the name of the local node.
Returns the name of the local node.
Returns the name of the local node.
Returns a new partisan_remote_ref. This is the same as calling partisan_remote_ref:from_term(erlang:make_ref()).
monitor(Term) deprecated

Sends a monitor request of type Type to the entity identified by Item. If the monitored entity does not exist or it changes monitored state, the caller of monitor/2 is notified by a message on the following format: {Tag, MonitorRef, Type, Object, Info}

Sends a monitor request of type Type to the entity identified by Item. If the monitored entity does not exist or it changes monitored state, the caller of monitor/2 is notified by a message on the following format

Monitor the status of the node Node. If Flag is true, monitoring is turned on. If Flag is false, monitoring is turned off.

The calling process subscribes or unsubscribes to node status change messages. A nodeup message is delivered to all subscribing processes when a new node is connected, and a nodedown message is delivered when a node is disconnected.
Returns the name of the local node.
Returns the node where Arg originates. Arg can be a process identifier, a reference, a port or a partisan remote refererence.

Returns the node specification of the local node. This is the information required when other nodes wish to join this node (See partisan_peer_service:join/1).

Return the partisan node_spec() for node named Node.

Return the tuple {ok, node_spec() for node named Node or the tuple {error, Reason}.

Returns a list of all nodes connected to this node via Partisan. Equivalent to erlang:nodes/1. Sames as calling nodes(visible).

Returns a list of all nodes connected to this node through normal connections (that is, hidden nodes are not listed). Same as nodes(visible).
Returns the name of the local node as a binary string.
Returns the partisan encoded pid for the calling process. This is the same as calling partisan_remote_ref:from_term(erlang:self()).
Start the application.
Stop the application.

Link to this section Types

-type actor() :: binary().
-type channel() :: atom().
-type channel_opts() :: #{parallelism := non_neg_integer(), monotonic => boolean()}.
-type forward_opts() :: partisan_peer_service_manager:forward_opts().
-type listen_addr() :: #{ip := inet:ip_address(), port := non_neg_integer()}.
-type message() :: term().
-type monitor_nodes_opt() :: nodedown_reason | {node_type, visible | hidden | all}.
-type monitor_process_id() ::
    erlang:monitor_process_identifier() | partisan_remote_ref:p() | partisan_remote_ref:n().
-type node_spec() ::
    #{name := node(), listen_addrs := [listen_addr()], channels := #{channel() => channel_opts()}}.
-type node_type() :: this | known | visible | connected | hidden | all.
-type server_ref() :: partisan_peer_service_manager:server_ref().

Link to this section Functions

Link to this function

broadcast(Broadcast, Mod)

View Source
-spec broadcast(any(), module()) -> ok.

Broadcasts a message originating from this node.

The message will be delivered to each node at least once. The Mod passed is responsible for handling the message on remote nodes as well as providing some other information both locally and and on other nodes. Mod must be loaded on all members of the clusters and implement the partisan_plumtree_broadcast_handler behaviour.
Link to this function

cast_message(ServerRef, Msg)

View Source
-spec cast_message(ServerRef :: server_ref(), Msg :: message()) -> ok.
Cast message to a remote ref
Link to this function

cast_message(ServerRef, Msg, Opts)

View Source
-spec cast_message(ServerRef :: server_ref(), Msg :: message(), Opts :: forward_opts()) -> ok.
Cast message to registered process on the remote side.
Link to this function

cast_message(Node, ServerRef, Msg, Opts)

View Source
-spec cast_message(Node :: node(), ServerRef :: server_ref(), Msg :: message(), Opts :: forward_opts()) ->
                ok.
Cast message to registered process on the remote side.
-spec channel_opts(Name :: channel()) -> channel_opts() | no_return().
Returns a channel with name Name. Fails if a channel named Name doesn't exist.
-spec default_channel() -> channel().
-spec demonitor(MonitorRef :: reference() | partisan_remote_ref:r()) -> true.
Link to this function

demonitor(MonitorRef, OptionList)

View Source
-spec demonitor(MonitorRef :: reference() | partisan_remote_ref:r(),
          OptionList :: partisan_monitor:demonitor_opts()) ->
             boolean().
-spec disconnect_node(Node :: node()) -> boolean() | ignored.
Link to this function

forward_message(ServerRef, Msg)

View Source
-spec forward_message(ServerRef :: server_ref(), Msg :: message()) -> ok.
Forward message to registered process on the remote side.
Link to this function

forward_message(ServerRef, Msg, Opts)

View Source
-spec forward_message(ServerRef :: server_ref(), Msg :: message(), Opts :: forward_opts()) -> ok.
Forward message to registered process on the remote side.
Link to this function

forward_message(Node, ServerRef, Msg, Opts)

View Source
-spec forward_message(Node :: node(),
                ServerRef :: server_ref(),
                Msg :: message(),
                Opts :: forward_opts()) ->
                   ok.
Forward message to registered process on the remote side.
-spec is_alive() -> boolean().
Returns true if the local node is alive (that is, if the node can be part of a distributed system), otherwise false.
Link to this function

is_connected(NodeOrSpec)

View Source
-spec is_connected(NodeOrSpec :: node_spec() | node()) -> boolean().
Returns the name of the local node.
Link to this function

is_connected(NodeOrSpec, Channel)

View Source
-spec is_connected(NodeOrSpec :: node_spec() | node(), Channel :: channel()) -> boolean().
Returns the name of the local node.
Link to this function

is_fully_connected(NodeOrSpec)

View Source
-spec is_fully_connected(NodeOrSpec :: node_spec() | node()) -> boolean().
Returns the name of the local node.
-spec is_local(Term) -> Result
            when
                Term ::
                    pid() |
                    port() |
                    reference() |
                    partisan_remote_ref:p() |
                    partisan_remote_ref:r(),
                Result :: boolean().
Returns the name of the local node.
-spec is_pid(pid() | partisan_remote_ref:p()) -> boolean() | no_return().
-spec is_process_alive(pid() | partisan_remote_ref:p()) -> boolean() | no_return().
Returns the name of the local node.
-spec is_reference(reference() | partisan_remote_ref:r()) -> boolean() | no_return().
Returns the name of the local node.
-spec make_ref() -> partisan_remote_ref:r().
Returns a new partisan_remote_ref. This is the same as calling partisan_remote_ref:from_term(erlang:make_ref()).
This function is deprecated. Use monitor/2 instead..
-spec monitor(process, monitor_process_id()) -> reference() | partisan_remote_ref:r() | no_return();
       (port, erlang:monitor_port_identifier()) -> reference() | no_return();
       (time_offset, clock_service) -> reference() | no_return().

Sends a monitor request of type Type to the entity identified by Item. If the monitored entity does not exist or it changes monitored state, the caller of monitor/2 is notified by a message on the following format: {Tag, MonitorRef, Type, Object, Info}

This is the Partisan's equivalent to erlang:monitor/2.

Failure: notalive if the partisan_monitor server is not alive.
Link to this function

monitor(Type, RegPid, Opts)

View Source
-spec monitor(process, monitor_process_id(), [erlang:monitor_option()]) ->
           reference() | partisan_remote_ref:r() | no_return();
       (port, erlang:monitor_port_identifier(), [erlang:monitor_option()]) ->
           reference() | no_return();
       (time_offset, clock_service, [erlang:monitor_option()]) -> reference() | no_return().

Sends a monitor request of type Type to the entity identified by Item. If the monitored entity does not exist or it changes monitored state, the caller of monitor/2 is notified by a message on the following format:

{Tag, MonitorRef, Type, Object, Info}

This is the Partisan's equivalent to erlang:monitor/2. It differs from the Erlang implementation only when monitoring a process. For all other cases (monitoring a port or time_offset) this function calls erlang:monitor/2.

Monitoring a `process`

Creates monitor between the current process and another process identified by Item, which can be a pid() (local or remote), an atom RegisteredName or a tuple {RegisteredName, Node}' for a registered process, located elsewhere.

In the case of a local pid() or a remote pid() A process monitor by name resolves the RegisteredName to pid() or port() only once at the moment of monitor instantiation, later changes to the name registration will not affect the existing monitor.

Failure: notalive if the partisan_monitor server is not alive.
Link to this function

monitor_node(Node, Flag)

View Source
-spec monitor_node(node() | node_spec(), boolean()) -> boolean().

Monitor the status of the node Node. If Flag is true, monitoring is turned on. If Flag is false, monitoring is turned off.

Making several calls to monitor_node(Node, true) for the same Node from is not an error; it results in as many independent monitoring instances as the number of different calling processes i.e. If a process has made two calls to monitor_node(Node, true) and Node terminates, only one nodedown message is delivered to the process (this differs from erlang:monitor_node/2).

If Node fails or does not exist, the message {nodedown, Node} is delivered to the calling process. If there is no connection to Node, a nodedown message is delivered. As a result when using a membership strategy that uses a partial view, you can not monitor nodes that are not members of the view.

If Node is the caller's node, the function returns false.
-spec monitor_nodes(Flag :: boolean()) -> ok | error | {error, term()}.
Link to this function

monitor_nodes(Flag, Opts)

View Source
-spec monitor_nodes(Flag :: boolean(), [monitor_nodes_opt()]) -> ok | error | {error, term()}.
The calling process subscribes or unsubscribes to node status change messages. A nodeup message is delivered to all subscribing processes when a new node is connected, and a nodedown message is delivered when a node is disconnected.
-spec node() -> node().
Returns the name of the local node.
-spec node(Term) -> Result
        when
            Term ::
                pid() | port() | reference() | partisan_remote_ref:p() | partisan_remote_ref:r(),
            Result :: node() | no_return().
Returns the node where Arg originates. Arg can be a process identifier, a reference, a port or a partisan remote refererence.
-spec node_spec() -> node_spec().

Returns the node specification of the local node. This is the information required when other nodes wish to join this node (See partisan_peer_service:join/1).

Notice that the values of the keys must be sorted for the peer service to be able to compare node specifications, and prevent duplicates in the membership view data structure. This is important in case you find yourself building this representation manually in order to implement a particular orchestration strategy. As Erlang maps are naturally sorted, the only property that you need to keep sorted is listen_addrs as it is implemented as a list.
-spec node_spec(node()) -> {ok, node_spec()} | {error, Reason :: any()}.

Return the partisan node_spec() for node named Node.

This function retrieves the node_spec() from the remote node using RPC and returns {error, Reason} if the RPC fails. Otherwise, asumes the node is running on the same host and returns a node_spec() with with nodename Name and host 'Host' and same metadata as myself/0.

If configuration option connect_disterl is true, the RPC will be implemented using the rpc module. Otherwise it will use partisan_rpc.

You should only use this function when distributed erlang is enabled (configuration option connect_disterl is true) or if the node is running on the same host and you are using this for testing purposes as there is no much sense in running a partisan cluster on a single host.
-spec node_spec(Node :: list() | node(), Opts :: #{rpc_timeout => timeout()}) ->
             {ok, node_spec()} | {error, Reason :: any()}.

Return the tuple {ok, node_spec() for node named Node or the tuple {error, Reason}.

This function first checks If there is a partisan connection to Node, if so returns the cached specification that was used for creating the connection. If no connection is present (the case for a p2p topology), then it tries to use @link partisan_rpc} to retrieve the node specification from the remote node. This later alternative requires the partisan configuration forward_opts` to have `broadcast and transitive enabled.

NOTICE: At the moment partisan_rpc might not work corrently w/ a p2p topology.
-spec nodes() -> [node()].

Returns a list of all nodes connected to this node via Partisan. Equivalent to erlang:nodes/1. Sames as calling nodes(visible).

Notice that if connect_disterl is true (possibly the case when testing), this function will NOT return the disterl nodes. For that you still need to call erlang:nodes/1.
-spec nodes(Arg :: node_type()) -> [node()].
Returns a list of all nodes connected to this node through normal connections (that is, hidden nodes are not listed). Same as nodes(visible).
-spec nodestring() -> binary().
Returns the name of the local node as a binary string.
-spec self() -> partisan_remote_ref:p().
Returns the partisan encoded pid for the calling process. This is the same as calling partisan_remote_ref:from_term(erlang:self()).
Start the application.
Stop the application.