Gearman-JobScheduler
view release on metacpan or search on metacpan
lib/Gearman/JobScheduler/Admin.pm view on Meta::CPAN
=head1 NAME
C<Gearman::JobScheduler::Admin> - Gearman administration utilities.
Reimplements functionality of "gearadmin"
(http://bazaar.launchpad.net/~tangent-trunk/gearmand/1.2/view/head:/bin/gearadmin.cc)
in Perl.
=cut
package Gearman::JobScheduler::Admin;
use strict;
use warnings;
use Modern::Perl "2012";
use Gearman::JobScheduler;
use Gearman::JobScheduler::Configuration;
# Neither "Gearman" nor "Gearman::XS" modules provide the administration
# functionality, so we'll connect directly to Gearman and send / receive
# commands ourselves.
use Net::Telnet;
# Connection timeout
use constant GJS_ADMIN_TIMEOUT => 10;
=head2 (static) C<server_version($config)>
Get the version number from all the configured servers.
Parameters:
=over 4
=item * Instance of Gearman::JobScheduler::Configuration
=back
Returns hashref of configured servers and their versions, e.g.:
=begin text
{
'localhost:4730' => '1.1.9',
# ...
}
=end text
Returns C<undef> on error.
=cut
sub server_version($)
{
my $config = shift;
unless ($config) {
die "Configuration is undefined.";
}
my $versions = {};
foreach my $server (@{$config->gearman_servers}) {
my $version = server_version_on_server($server);
unless (defined $version) {
say STDERR "Unable to determine version of server $server.";
return undef;
}
$versions->{ $server } = $version;
}
( run in 2.819 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )