Elixir v1.3.3 Node View Source

Functions related to VM nodes.

Some of the functions in this module are inlined by the compiler, similar to functions in the Kernel module and they are explicitly marked in their docs as “inlined by the compiler”. For more information about inlined functions, check out the Kernel module.

Link to this section Summary

Functions

Returns true if the local node is alive

Establishes a connection to node

Forces the disconnection of a node

Returns the magic cookie of the local node

Returns a list of all visible nodes in the system, excluding the local node

Returns a list of nodes according to argument given

Monitors the status of the node

Behaves as monitor/2 except that it allows an extra option to be given, namely :allow_passive_connect

Tries to set up a connection to node

Returns the current node

Sets the magic cookie of node to the atom cookie

Returns the pid of a new process started by the application of fun on node. If node does not exist, a useless pid is returned

Returns the pid of a new process started by the application of fun on node

Returns the pid of a new process started by the application of module.function(args) on node

Returns the pid of a new process started by the application of module.function(args) on node

Returns the pid of a new linked process started by the application of fun on node

Returns the pid of a new linked process started by the application of module.function(args) on node

Turns a non-distributed node into a distributed node

Turns a distributed node into a non-distributed node

Link to this section Types

Link to this section Functions

Link to this function alive?() View Source
alive?() :: boolean

Returns true if the local node is alive.

That is, if the node can be part of a distributed system.

Link to this function connect(node) View Source
connect(t) :: boolean | :ignored

Establishes a connection to node.

Returns true if successful, false if not, and the atom :ignored if the local node is not alive.

For more information, see :erlang.connect_node/1.

Link to this function disconnect(node) View Source
disconnect(t) :: boolean | :ignored

Forces the disconnection of a node.

This will appear to the node as if the local node has crashed. This function is mainly used in the Erlang network authentication protocols. Returns true if disconnection succeeds, otherwise false. If the local node is not alive, the function returns :ignored.

For more information, see :erlang.disconnect_node/1.

Returns the magic cookie of the local node.

Returns the cookie if the node is alive, otherwise :nocookie.

Returns a list of all visible nodes in the system, excluding the local node.

Same as list(:visible).

Link to this function list(args) View Source
list(state | [state]) :: [t]

Returns a list of nodes according to argument given.

The result returned when the argument is a list, is the list of nodes satisfying the disjunction(s) of the list elements.

For more information, see :erlang.nodes/1.

Link to this function monitor(node, flag) View Source
monitor(t, boolean) :: true

Monitors the status of the node.

If flag is true, monitoring is turned on. If flag is false, monitoring is turned off.

For more information, see :erlang.monitor_node/2.

Link to this function monitor(node, flag, options) View Source
monitor(t, boolean, [:allow_passive_connect]) :: true

Behaves as monitor/2 except that it allows an extra option to be given, namely :allow_passive_connect.

For more information, see :erlang.monitor_node/3.

Link to this function ping(node) View Source
ping(t) :: :pong | :pang

Tries to set up a connection to node.

Returns :pang if it fails, or :pong if it is successful.

Examples

iex> Node.ping(:unknown_node)
:pang

Returns the current node.

It returns the same as the built-in node().

Link to this function set_cookie(node \\ Node.self(), cookie) View Source

Sets the magic cookie of node to the atom cookie.

The default node is Node.self/0, the local node. If node is the local node, the function also sets the cookie of all other unknown nodes to cookie.

This function will raise FunctionClauseError if the given node is not alive.

Link to this function spawn(node, fun) View Source
spawn(t, (() -> any)) :: pid

Returns the pid of a new process started by the application of fun on node. If node does not exist, a useless pid is returned.

For the list of available options, see :erlang.spawn/2.

Inlined by the compiler.

Link to this function spawn(node, fun, opts) View Source
spawn(t, (() -> any), Process.spawn_opts) ::
  pid |
  {pid, reference}

Returns the pid of a new process started by the application of fun on node.

If node does not exist, a useless pid is returned.

For the list of available options, see :erlang.spawn_opt/3.

Inlined by the compiler.

Link to this function spawn(node, module, fun, args) View Source
spawn(t, module, atom, [any]) :: pid

Returns the pid of a new process started by the application of module.function(args) on node.

If node does not exist, a useless pid is returned.

For the list of available options, see :erlang.spawn/4.

Inlined by the compiler.

Link to this function spawn(node, module, fun, args, opts) View Source
spawn(t, module, atom, [any], Process.spawn_opts) ::
  pid |
  {pid, reference}

Returns the pid of a new process started by the application of module.function(args) on node.

If node does not exist, a useless pid is returned.

For the list of available options, see :erlang.spawn/5.

Inlined by the compiler.

Link to this function spawn_link(node, fun) View Source
spawn_link(t, (() -> any)) :: pid

Returns the pid of a new linked process started by the application of fun on node.

A link is created between the calling process and the new process, atomically. If node does not exist, a useless pid is returned (and due to the link, an exit signal with exit reason :noconnection will be received).

Inlined by the compiler.

Link to this function spawn_link(node, module, fun, args) View Source
spawn_link(t, module, atom, [any]) :: pid

Returns the pid of a new linked process started by the application of module.function(args) on node.

A link is created between the calling process and the new process, atomically. If node does not exist, a useless pid is returned (and due to the link, an exit signal with exit reason :noconnection will be received).

Inlined by the compiler.

Link to this function start(name, type \\ :longnames, tick_time \\ 15000) View Source
start(node, :longnames | :shortnames, non_neg_integer) ::
  {:ok, pid} |
  {:error, term}

Turns a non-distributed node into a distributed node.

This functionality starts the :net_kernel and other related processes.

Link to this function stop() View Source
stop() :: :ok | {:error, :not_allowed | :not_found}

Turns a distributed node into a non-distributed node.

For other nodes in the network, this is the same as the node going down. Only possible when the node was started with Node.start/3, otherwise returns {:error, :not_allowed}. Returns {:error, :not_found} if the local node is not alive.