AnyEvent-Consul-Exec
view release on metacpan or search on metacpan
lib/AnyEvent/Consul/Exec.pm view on Meta::CPAN
# command to run
command => 'uptime',
# number of seconds target will wait for command, without sending
# output, before terminating it
wait => 2,
# called once job is submitted to Consul
on_submit => sub {
say "job submitted";
},
# called as each target node starts to process the job
# multiple calls, once per node
on_ack => sub {
my ($node) = @_;
say "$node: ack";
},
# called when a node has output from the job
# can be called zero or more times per node, as more output
# becomes available
on_output => sub {
my ($node, $output) = @_;
say "$node: output:";
say "$node> $_" for split("\n", $output);
},
# called when the node completes a job
# multiple calls, one per node
on_exit => sub {
my ($node, $rc) = @_;
say "$node: exit: $rc";
},
# called once all nodes have reported completion
# object is unusable past this point
on_done => sub {
say "job done";
$cv->send;
},
# called if an error occurs anywhere during processing (not command errors)
# typically called if Consul is unable to service requests
# object is unusable past this point
on_error => sub {
my ($err) = @_;
say "error: $err";
$cv->send;
},
);
# begin execution
$e->start;
$cv->recv;
=head1 DESCRIPTION
( run in 0.315 second using v1.01-cache-2.11-cpan-a1f116cd669 )