Argon
view release on metacpan or search on metacpan
bin/ar-manager view on Meta::CPAN
use warnings;
use AnyEvent;
use Argon::Log;
use Argon::Manager;
use Getopt::Long::Descriptive;
my ($opt, $usage) = describe_options(
'manager %o',
['key|k=s', '(required) path to file containing encryption key', {required => 1}],
['host|h=s', '(optional) hostname on which to listen (defaults to localhost)'],
['port|p=i', '(optional) port on which to listen (defaults to OS-assigned port)', {callbacks => {'port number' => sub { shift > 0 }}}],
['persist=s', '(optional, also doesn\'t work yet) maintain a persistent copy of the message queue'],
['verbose|v=i', '(optional) level of verbosity (1 - 9; defaults to 5 [warn])', {default => 'warn'}],
[],
['help|h', 'prints this help text and exits', {shortcircuit => 1}],
['usage|u', 'prints this help text and exits', {shortcircuit => 1}],
);
if ($opt->help) {
print $usage->text;
exit;
bin/ar-worker view on Meta::CPAN
use strict;
use warnings;
use AnyEvent;
use Argon::Log;
use Argon::Worker;
use Getopt::Long::Descriptive;
my ($opt, $usage) = describe_options(
'worker %o',
['key|k=s', '(required) path to file containing encryption key', {required => 1}],
['capacity|c=i', '(required) max number of worker processes permitted', {required => 1, callbacks => {'positive int' => sub { shift > 0 }}}],
['mgr|m=s', '(required) address of Argon manager service (e.g. some.host.com:4242)', {required => 1, callbacks => {'host:port' => sub { shift =~ /^.+?:\d+$/ }}}],
['allow-eval|a', '(optional) permit execution of serialized code (warning: this is a security risk if not running in a safe environment)'],
['verbose|v=i', '(optional) level of verbosity (1 - 9; defaults to 5 [warn])', {default => 'warn'}],
[],
['help|h', 'prints this help text and exits', {shortcircuit => 1}],
['usage|u', 'prints this help text and exits', {shortcircuit => 1}],
);
if ($opt->help) {
print $usage->text;
exit;
lib/Argon/Client.pm view on Meta::CPAN
qw(key keyfile cipher token);
}
$class->$orig(%args);
};
sub BUILD {
my ($self, $args) = @_;
if ($self->channel) {
# Set callbacks
$self->channel->on_msg(K('_notify', $self));
$self->channel->on_err(K('_error', $self));
$self->channel->on_close(K('_close', $self));
if ($self->channel->is_ready) {
$self->opened->();
$self->ready->();
} else {
$self->channel->on_ready(K('_ready', $self));
$self->opened->();
t/Argon/Client.t view on Meta::CPAN
ok my $client = Argon::Client->new(
host => 'localhost',
port => 4242,
channel => $left,
@_,
), 'client';
return ($client, $right);
}
subtest 'callbacks' => sub {
ar_test 'positive path' => sub {
my $cv = shift;
my ($opened, $ready, $closed, $failed, $notify) = @_;
my ($client, $ch); ($client, $ch) = client(
opened => sub { $opened = 1 },
ready => sub { $ready = 1 },
failed => sub { $failed = 1 },
closed => sub { $closed = 1; $cv->send; },
notify => sub { $notify = 1; $ch->disconnect; },
( run in 1.016 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )