Gearman-JobScheduler
view release on metacpan or search on metacpan
lib/Gearman/JobScheduler.pm view on Meta::CPAN
=head1 NAME
C<Gearman::JobScheduler> - Gearman job scheduler utilities.
=cut
package Gearman::JobScheduler;
$VERSION = '0.16';
use strict;
use warnings;
use Modern::Perl "2012";
use Gearman::JobScheduler::Configuration;
use Gearman::XS qw(:constants);
use Gearman::XS::Client;
# Hashref serializing / unserializing
use Data::Compare;
use Data::Dumper;
use JSON;
# serialize hashes with the same key order:
my $json = JSON->new->allow_nonref->canonical->utf8;
use Data::UUID;
use File::Path qw(make_path);
use Digest::SHA qw(sha256_hex);
use Carp;
use Email::MIME;
use Email::Sender::Simple qw(try_to_sendmail);
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({
level => $DEBUG,
utf8=>1,
layout => "%d{ISO8601} [%P]: %m%n"
});
# flush sockets after every write
$| = 1;
# Max. job ID length for GJS jobs (when GJS comes up with a job ID of its own)
use constant GJS_JOB_ID_MAX_LENGTH => 256;
=head2 (static) C<job_status($function_name, $gearman_job_id[, $config])>
Get Gearman job status.
Parameters:
=over 4
=item * Gearman function name (e.g. "NinetyNineBottlesOfBeer")
=item * Gearman job ID (e.g. "H:localhost.localdomain:8")
=item * (optional) Instance of Gearman::JobScheduler::Configuration
=back
Returns hashref with the job status, e.g.:
=begin text
( run in 1.716 second using v1.01-cache-2.11-cpan-5a3173703d6 )