NAME
AnyEvent::MP::Kernel - the actual message passing kernel
SYNOPSIS
use AnyEvent::MP::Kernel;
DESCRIPTION
This module provides most of the basic functionality of AnyEvent::MP, exposed through higher level interfaces such as AnyEvent::MP and Coro::MP.
This module is mainly of interest when knowledge about connectivity, connected nodes etc. is sought.
GLOBALS AND FUNCTIONS
- $AnyEvent::MP::Kernel::WARN->($level, $msg)
-
This value is called with an error or warning message, when e.g. a connection could not be created, authorisation failed and so on.
It must not block or send messages -queue it and use an idle watcher if you need to do any of these things.
$level
sould be0
for messages ot be logged always,1
for unexpected messages and errors,2
for warnings,7
for messages about node connectivity and services,8
for debugging messages and9
for tracing messages.The default simply logs the message to STDERR.
- $AnyEvent::MP::Kernel::WARNLEVEL [default 5 or $ENV{PERL_ANYEVENT_MP_WARNLEVEL}]
-
The maximum level at which warning messages will be printed to STDERR by the default warn handler.
- $is_local = port_is_local $port
-
Returns true iff the port is a local port.
- snd_to_func $node, $func, @args
-
Expects a node ID and a name of a function. Asynchronously tries to call this function with the given arguments on that node.
This function can be used to implement
spawn
-like interfaces. - snd_on $node, @msg
-
Executes
snd
with the given@msg
(which must include the destination port) on the given node. - eval_on $node, $string[, @reply]
-
Evaluates the given string as Perl expression on the given node. When @reply is specified, then it is used to construct a reply message with
"$@"
and any results from the eval appended. - node_is_known $nodeid
-
Returns true iff the given node is currently known to the system.
- node_is_up $nodeid
-
Returns true if the given node is "up", that is, the kernel thinks it has a working connection to it.
If the node is known but not currently connected, returns
0
. If the node is not known, returnsundef
. - known_nodes
-
Returns the node IDs of all nodes currently known to this node, including itself and nodes not currently connected.
- up_nodes
-
Return the node IDs of all nodes that are currently connected (excluding the node itself).
- $guard = mon_nodes $callback->($nodeid, $is_up, @reason)
-
Registers a callback that is called each time a node goes up (a connection is established) or down (the connection is lost).
Node up messages can only be followed by node down messages for the same node, and vice versa.
Note that monitoring a node is usually better done by monitoring it's node port. This function is mainly of interest to modules that are concerned about the network topology and low-level connection handling.
Callbacks must not block and should not send any messages.
The function returns an optional guard which can be used to unregister the monitoring callback again.
SEE ALSO
AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/