AnyEvent-MP
view release on metacpan or search on metacpan
value so that they will actually all be tried within the monitor timeout
interval.
C<2> is usually a good value, unless you live in new zealand.
=item [set|del]framing_format [array]
Configures the list of framing formats offered to the other side. This is
simply a list of formatted read/write types used with L<AnyEvent::Handle>,
in order of decreasing preference.
Nodes support C<cbor>, C<json> and C<storable> framing formats for data
packets out of the box, and usually choose C<cbor> because it is first in
the list.
Example: prefer the C<My::Personal::Format> framing format over JSON over
Storable.
aemp setframing_format '["My::Personal::Format", "json", "storable"]'
=item [set|del]auth_offer [array]
Configures the list of authentication types that the node offers to the
other side as acceptable, in order of decreasing preference. Only auth
methods that the node can actually support will be offered.
The default is '["tls_sha3_512", "hmac_sha3_512"]' and is usually good
enough.
=item [set|del]auth_accept [array]
Configures the list of authentication types that remote nodes can use to
authenticate, in order of decreasing preference.
The default is '["tls_sha3_512", "hmac_sha3_512", "tls_anon",
"cleartext"]' and is usually good enough.
=item [set|del]autocork <boolean>
Sets the default C<autocork> option value for the L<AnyEvent::Handle>
object used by transports. By default, autocorking is off, potentially
reducing latency.
=item [set|del]nodelay <boolean>
Sets the default C<nodelay> option value for the L<AnyEvent::Handle>
object used by transports. By default, nodelay is on, potentially reducing
latency.
=back
=cut
use common::sense;
# should come before anything else, so all modules
# will be loaded on each restart
BEGIN {
if (@ARGV == 1 && $ARGV[0] =~ /^\[/) {
require JSON::XS;
@ARGV = @{ JSON::XS->new->utf8->decode (shift) };
} else {
for (@ARGV) {
if (/^[\[\{\"]/) {
require JSON::XS;
$_ = JSON::XS->new->utf8->allow_nonref->decode ($_);
}
}
}
if ($ARGV[0] eq "run") {
shift;
# d'oh
require AnyEvent::Watchdog;
# only now can we load additional modules
require AnyEvent;
require AnyEvent::Watchdog::Util;
AnyEvent::Watchdog::Util::autorestart (1);
AnyEvent::Watchdog::Util::heartbeat (300);
require AnyEvent::MP::Kernel;
AnyEvent::MP::Kernel::configure (@ARGV);
AnyEvent::detect () eq "AnyEvent::Impl::EV"
? EV::loop ()
: AE::cv ()->recv;
}
}
use Carp ();
use JSON::XS;
use AnyEvent;
use AnyEvent::Util;
use AnyEvent::MP;
use AnyEvent::MP::Config;
sub my_run_cmd {
my ($cmd) = @_;
my $cv = &run_cmd;
my $status = $cv->recv;
$status
and die "@$cmd: command failed with exit status $status.";
}
sub gen_cert {
my_run_cmd [qw(openssl req
-new -nodes -x509 -days 3650
-newkey rsa:2048 -keyout /dev/fd/3
-batch -subj /CN=AnyEvent::MP
)],
"<", "/dev/null",
">" , \my $cert,
"3>", \my $key,
"2>", "/dev/null";
"$cert$key"
}
( run in 0.664 second using v1.01-cache-2.11-cpan-39bf76dae61 )