… | |
… | |
39 | |
39 | |
40 | =head1 CURRENT STATUS |
40 | =head1 CURRENT STATUS |
41 | |
41 | |
42 | bin/aemp - stable. |
42 | bin/aemp - stable. |
43 | AnyEvent::MP - stable API, should work. |
43 | AnyEvent::MP - stable API, should work. |
44 | AnyEvent::MP::Intro - uptodate, but incomplete. |
44 | AnyEvent::MP::Intro - explains most concepts. |
45 | AnyEvent::MP::Kernel - mostly stable. |
45 | AnyEvent::MP::Kernel - mostly stable. |
46 | AnyEvent::MP::Global - stable API, protocol not yet final. |
46 | AnyEvent::MP::Global - stable API, protocol not yet final. |
47 | |
47 | |
48 | stay tuned. |
48 | stay tuned. |
49 | |
49 | |
… | |
… | |
54 | Despite its simplicity, you can securely message other processes running |
54 | Despite its simplicity, you can securely message other processes running |
55 | on the same or other hosts, and you can supervise entities remotely. |
55 | on the same or other hosts, and you can supervise entities remotely. |
56 | |
56 | |
57 | For an introduction to this module family, see the L<AnyEvent::MP::Intro> |
57 | For an introduction to this module family, see the L<AnyEvent::MP::Intro> |
58 | manual page and the examples under F<eg/>. |
58 | manual page and the examples under F<eg/>. |
59 | |
|
|
60 | At the moment, this module family is a bit underdocumented. |
|
|
61 | |
59 | |
62 | =head1 CONCEPTS |
60 | =head1 CONCEPTS |
63 | |
61 | |
64 | =over 4 |
62 | =over 4 |
65 | |
63 | |
… | |
… | |
160 | |
158 | |
161 | =item $nodeid = node_of $port |
159 | =item $nodeid = node_of $port |
162 | |
160 | |
163 | Extracts and returns the node ID from a port ID or a node ID. |
161 | Extracts and returns the node ID from a port ID or a node ID. |
164 | |
162 | |
|
|
163 | =item configure $profile, key => value... |
|
|
164 | |
165 | =item configure key => value... |
165 | =item configure key => value... |
166 | |
166 | |
167 | Before a node can talk to other nodes on the network (i.e. enter |
167 | Before a node can talk to other nodes on the network (i.e. enter |
168 | "distributed mode") it has to configure itself - the minimum a node needs |
168 | "distributed mode") it has to configure itself - the minimum a node needs |
169 | to know is its own name, and optionally it should know the addresses of |
169 | to know is its own name, and optionally it should know the addresses of |
… | |
… | |
176 | |
176 | |
177 | =item step 1, gathering configuration from profiles |
177 | =item step 1, gathering configuration from profiles |
178 | |
178 | |
179 | The function first looks up a profile in the aemp configuration (see the |
179 | The function first looks up a profile in the aemp configuration (see the |
180 | L<aemp> commandline utility). The profile name can be specified via the |
180 | L<aemp> commandline utility). The profile name can be specified via the |
181 | named C<profile> parameter. If it is missing, then the nodename (F<uname |
181 | named C<profile> parameter or can simply be the first parameter). If it is |
182 | -n>) will be used as profile name. |
182 | missing, then the nodename (F<uname -n>) will be used as profile name. |
183 | |
183 | |
184 | The profile data is then gathered as follows: |
184 | The profile data is then gathered as follows: |
185 | |
185 | |
186 | First, all remaining key => value pairs (all of which are conviniently |
186 | First, all remaining key => value pairs (all of which are conveniently |
187 | undocumented at the moment) will be interpreted as configuration |
187 | undocumented at the moment) will be interpreted as configuration |
188 | data. Then they will be overwritten by any values specified in the global |
188 | data. Then they will be overwritten by any values specified in the global |
189 | default configuration (see the F<aemp> utility), then the chain of |
189 | default configuration (see the F<aemp> utility), then the chain of |
190 | profiles chosen by the profile name (and any C<parent> attributes). |
190 | profiles chosen by the profile name (and any C<parent> attributes). |
191 | |
191 | |
… | |
… | |
491 | number of C<@reason> elements (no @reason means that the port was deleted |
491 | number of C<@reason> elements (no @reason means that the port was deleted |
492 | "normally"). Note also that I<< the callback B<must> never die >>, so use |
492 | "normally"). Note also that I<< the callback B<must> never die >>, so use |
493 | C<eval> if unsure. |
493 | C<eval> if unsure. |
494 | |
494 | |
495 | In the second form (another port given), the other port (C<$rcvport>) |
495 | In the second form (another port given), the other port (C<$rcvport>) |
496 | will be C<kil>'ed with C<@reason>, iff a @reason was specified, i.e. on |
496 | will be C<kil>'ed with C<@reason>, if a @reason was specified, i.e. on |
497 | "normal" kils nothing happens, while under all other conditions, the other |
497 | "normal" kils nothing happens, while under all other conditions, the other |
498 | port is killed with the same reason. |
498 | port is killed with the same reason. |
499 | |
499 | |
500 | The third form (kill self) is the same as the second form, except that |
500 | The third form (kill self) is the same as the second form, except that |
501 | C<$rvport> defaults to C<$SELF>. |
501 | C<$rvport> defaults to C<$SELF>. |
… | |
… | |
504 | C<snd>. |
504 | C<snd>. |
505 | |
505 | |
506 | As a rule of thumb, monitoring requests should always monitor a port from |
506 | As a rule of thumb, monitoring requests should always monitor a port from |
507 | a local port (or callback). The reason is that kill messages might get |
507 | a local port (or callback). The reason is that kill messages might get |
508 | lost, just like any other message. Another less obvious reason is that |
508 | lost, just like any other message. Another less obvious reason is that |
509 | even monitoring requests can get lost (for exmaple, when the connection |
509 | even monitoring requests can get lost (for example, when the connection |
510 | to the other node goes down permanently). When monitoring a port locally |
510 | to the other node goes down permanently). When monitoring a port locally |
511 | these problems do not exist. |
511 | these problems do not exist. |
512 | |
512 | |
513 | Example: call a given callback when C<$port> is killed. |
513 | Example: call a given callback when C<$port> is killed. |
514 | |
514 | |
… | |
… | |
707 | |
707 | |
708 | =item * Node IDs are arbitrary strings in AEMP. |
708 | =item * Node IDs are arbitrary strings in AEMP. |
709 | |
709 | |
710 | Erlang relies on special naming and DNS to work everywhere in the same |
710 | Erlang relies on special naming and DNS to work everywhere in the same |
711 | way. AEMP relies on each node somehow knowing its own address(es) (e.g. by |
711 | way. AEMP relies on each node somehow knowing its own address(es) (e.g. by |
712 | configuraiton or DNS), but will otherwise discover other odes itself. |
712 | configuration or DNS), but will otherwise discover other odes itself. |
713 | |
713 | |
714 | =item * Erlang has a "remote ports are like local ports" philosophy, AEMP |
714 | =item * Erlang has a "remote ports are like local ports" philosophy, AEMP |
715 | uses "local ports are like remote ports". |
715 | uses "local ports are like remote ports". |
716 | |
716 | |
717 | The failure modes for local ports are quite different (runtime errors |
717 | The failure modes for local ports are quite different (runtime errors |
… | |
… | |
730 | |
730 | |
731 | Erlang uses processes that selectively receive messages, and therefore |
731 | Erlang uses processes that selectively receive messages, and therefore |
732 | needs a queue. AEMP is event based, queuing messages would serve no |
732 | needs a queue. AEMP is event based, queuing messages would serve no |
733 | useful purpose. For the same reason the pattern-matching abilities of |
733 | useful purpose. For the same reason the pattern-matching abilities of |
734 | AnyEvent::MP are more limited, as there is little need to be able to |
734 | AnyEvent::MP are more limited, as there is little need to be able to |
735 | filter messages without dequeing them. |
735 | filter messages without dequeuing them. |
736 | |
736 | |
737 | (But see L<Coro::MP> for a more Erlang-like process model on top of AEMP). |
737 | (But see L<Coro::MP> for a more Erlang-like process model on top of AEMP). |
738 | |
738 | |
739 | =item * Erlang sends are synchronous, AEMP sends are asynchronous. |
739 | =item * Erlang sends are synchronous, AEMP sends are asynchronous. |
740 | |
740 | |