AnyEvent-MP

 view release on metacpan or  search on metacpan

MP.pm  view on Meta::CPAN

  };

=item Nodes not longer connect to all other nodes.

In AEMP 1.x, every node automatically loads the L<AnyEvent::MP::Global>
module, which in turn would create connections to all other nodes in the
network (helped by the seed nodes).

In version 2.x, global nodes still connect to all other global nodes, but
other nodes don't - now every node either is a global node itself, or
attaches itself to another global node.

If a node isn't a global node itself, then it attaches itself to one
of its seed nodes. If that seed node isn't a global node yet, it will
automatically be upgraded to a global node.

So in many cases, nothing needs to be changed - one just has to make sure
that all seed nodes are meshed together with the other seed nodes (as with
AEMP 1.x), and other nodes specify them as seed nodes. This is most easily
achieved by specifying the same set of seed nodes for all nodes in the
network.

Not opening a connection to every other node is usually an advantage,

MP/Intro.pod  view on Meta::CPAN

There are plenty of possibilities you can use - it's all up to you how you
structure your application.

=head1 PART 4: Coro::MP - selective receive

Not all problems lend themselves naturally to an event-based solution:
sometimes things are easier if you can decide in what order you want to
receive messages, regardless of the order in which they were sent.

In these cases, L<Coro::MP> can provide a nice solution: instead of
registering callbacks for each message type, C<Coro::MP> attaches a
(coro-) thread to a port. The thread can then opt to selectively receive
messages it is interested in. Other messages are not lost, but queued, and
can be received at a later time.

The C<Coro::MP> module is not part of L<AnyEvent::MP>, but a separate
module. It is, however, tightly integrated into C<AnyEvent::MP> - the
ports it creates are fully compatible to C<AnyEvent::MP> ports.

In fact, C<Coro::MP> is more of an extension than a separate module: all
functions exported by C<AnyEvent::MP> are exported by it as well.

MP/Intro.pod  view on Meta::CPAN

   };

   mon $ioserver, sub {
      warn "ioserver was killed: @_\n";
   }; 

Let's go through it, section by section.

   my $ioserver = port_async {

Ports can be created by attaching a thread to an existing port via
C<rcv_async>, or as in this example, by calling C<port_async> with the
code to execute as a thread. The C<async> component comes from the fact
that threads are created using the C<Coro::async> function.

The thread runs in a normal port context (so C<$SELF> is set). In
addition, when the thread returns, it will be C<kil> I<normally>, i.e.
without a reason argument.

      while () {
         my ($tag, $port, $path) = get_cond;

MP/LogCatcher.pm  view on Meta::CPAN

=head1 NAME

AnyEvent::MP::LogCatcher - catch all logs from all nodes

=head1 SYNOPSIS

   use AnyEvent::MP::LogCatcher;

=head1 DESCRIPTION

This relatively simple module attaches itself to the
C<$AnyEvent::Log::COLLECT> context on every node and sends all log
messages to the node showing interest via the C<catch> function.

No attempt to buffer log messages on connection loss, or to retransmit
lost messages, is done.

=head1 GLOBALS AND FUNCTIONS

=over 4

MP/LogCatcher.pm  view on Meta::CPAN

      level  => $loglevel,
      log_cb => sub {
         snd $rport, @{ $_[0] }
            if $PROPAGATE;
      },
      fmt_cb => sub {
         [$_[0], $_[1]->title, $_[2], $_[3]]
      },
   ;

   $AnyEvent::Log::COLLECT->attach ($ctx);

   # monitor them, silently die if they die
   mon $rport, sub {
      $AnyEvent::Log::COLLECT->detach ($ctx);
   };

   AE::log 8 => "starting to propagate log messages to $rport";
}

sub mon_node {

README  view on Meta::CPAN

             ...
          };

    Nodes not longer connect to all other nodes.
        In AEMP 1.x, every node automatically loads the AnyEvent::MP::Global
        module, which in turn would create connections to all other nodes in
        the network (helped by the seed nodes).

        In version 2.x, global nodes still connect to all other global
        nodes, but other nodes don't - now every node either is a global
        node itself, or attaches itself to another global node.

        If a node isn't a global node itself, then it attaches itself to one
        of its seed nodes. If that seed node isn't a global node yet, it
        will automatically be upgraded to a global node.

        So in many cases, nothing needs to be changed - one just has to make
        sure that all seed nodes are meshed together with the other seed
        nodes (as with AEMP 1.x), and other nodes specify them as seed
        nodes. This is most easily achieved by specifying the same set of
        seed nodes for all nodes in the network.

        Not opening a connection to every other node is usually an



( run in 1.925 second using v1.01-cache-2.11-cpan-e1769b4cff6 )