--- AnyEvent-MP/MP.pm 2009/08/17 03:56:34 1.59 +++ AnyEvent-MP/MP.pm 2009/08/27 21:29:37 1.63 @@ -13,9 +13,7 @@ $SELF # receiving/own port id in rcv callbacks # initialise the node so it can send/receive messages - initialise_node; # -OR- - initialise_node "localhost:4040"; # -OR- - initialise_node "slave/", "localhost:4040" + initialise_node; # ports are message endpoints @@ -74,7 +72,7 @@ Ports allow you to register C handlers that can match all or just some messages. Messages will not be queued. -=item port id - C +=item port ID - C A port ID is the concatenation of a noderef, a hash-mark (C<#>) as separator, and a port name (a printable string of unspecified format). An @@ -87,12 +85,13 @@ which provides nodes to manage each other remotely, and to create new ports. -Nodes are either private (single-process only), slaves (connected to a -master node only) or public nodes (connectable from unrelated nodes). +Nodes are either private (single-process only), slaves (can only talk to +public nodes, but do not need an open port) or public nodes (connectable +from any other node). -=item noderef - C, C, C +=item node ID - C<[a-za-Z0-9_\-.:]+> -A node reference is a string that either simply identifies the node (for +A node ID is a string that either simply identifies the node (for private and slave nodes), or contains a recipe on how to reach a given node (for public nodes). @@ -130,7 +129,7 @@ our @EXPORT = qw( NODE $NODE *SELF node_of after resolve_node initialise_node - snd rcv mon kil reg psub spawn + snd rcv mon mon_guard kil reg psub spawn port ); @@ -145,16 +144,14 @@ =item $thisnode = NODE / $NODE The C function returns, and the C<$NODE> variable contains the -noderef of the local node. The value is initialised by a call to +node id of the local node. The value is initialised by a call to C. -=item $noderef = node_of $port - -Extracts and returns the noderef from a port ID or a noderef. +=item $nodeid = node_of $port -=item initialise_node $noderef, $seednode, $seednode... +Extracts and returns the noderef from a port ID or a node ID. -=item initialise_node "slave/", $master, $master... +=item initialise_node $profile_name Before a node can talk to other nodes on the network it has to initialise itself - the minimum a node needs to know is it's own name, and optionally @@ -182,36 +179,28 @@ C or indirectly via a profile or the nodename) must be a noderef (possibly unresolved, in which case it will be resolved). -After resolving, the node will bind itself on all endpoints and try to -connect to all additional C<$seednodes> that are specified. Seednodes are -optional and can be used to quickly bootstrap the node into an existing -network. +After resolving, the node will bind itself on all endpoints. =item slave nodes When the C<$noderef> (either as given or overriden by the config file) is the special string C, then the node will become a slave -node. Slave nodes cannot be contacted from outside and will route most of -their traffic to the master node that they attach to. +node. Slave nodes cannot be contacted from outside, and cannot talk to +each other (at least in this version of AnyEvent::MP). -At least one additional noderef is required (either by specifying it -directly or because it is part of the configuration profile): The node -will try to connect to all of them and will become a slave attached to the -first node it can successfully connect to. - -Note that slave nodes cannot change their name, and consequently, their -master, so if the master goes down, the slave node will not function well -anymore until it can re-establish conenciton to its master. This makes -slave nodes unsuitable for long-term nodes or fault-tolerant networks. +Slave nodes work by creating connections to all public nodes, using the +L service. =back -This function will block until all nodes have been resolved and, for slave -nodes, until it has successfully established a connection to a master -server. +After initialising itself, the node will connect to all additional +C<$seednodes> that are specified diretcly or via a profile. Seednodes are +optional and can be used to quickly bootstrap the node into an existing +network. All the seednodes will also be specially marked to automatically retry -connecting to them infinitely. +connecting to them indefinitely, so make sure that seednodes are really +reliable and up (this might also change in the future). Example: become a public node listening on the guessed noderef, or the one specified via C for the current node. This should be the most common @@ -224,11 +213,6 @@ initialise_node "slave/"; -Example: become a slave node to any of the specified master servers. This -form is also often used for commandline clients. - - initialise_node "slave/", "master1", "192.168.13.17", "mp.example.net"; - Example: become a public node, and try to contact some well-known master servers to become part of the network.