MediaCloud-JobManager
view release on metacpan or search on metacpan
lib/MediaCloud/JobManager/Job.pm view on Meta::CPAN
=head1 NAME
C<MediaCloud::JobManager::Job> - An abstract class for a "function".
=head1 LINGO
=over 4
=item * function
A function to be run by locally or remotely, e.g. C<add_default_feeds>.
=item * job
An instance of the function doing the actual job with specific parameters.
=back
=cut
package MediaCloud::JobManager::Job;
use strict;
use warnings;
use Modern::Perl "2012";
use feature qw(switch);
use Moose::Role 2.1005;
use MediaCloud::JobManager; # helper subroutines
use MediaCloud::JobManager::Configuration;
use Time::HiRes;
use Data::Dumper;
use DateTime;
use Readonly;
# used for capturing STDOUT and STDERR output of each job and timestamping it;
# initialized before each job
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init(
{
level => $DEBUG,
utf8 => 1,
layout => "%d{ISO8601} [%P]: %m%n"
}
);
=head1 ABSTRACT INTERFACE
The following subroutines must be implemented by the subclasses of this class.
=head2 REQUIRED
=head3 C<run($self, $args)>
Run the job.
Parameters:
=over 4
=item * C<$self>, a reference to the instance of the function class
=item * (optional) C<$args> (hashref), arguments needed for running the
function
=back
An instance (object) of the class will be created before each run. Class
instance variables (e.g. C<$self-E<gt>_my_variable>) will be discarded after
each run.
Returns result on success (serializable by the L<JSON> module). The result will
be discarded if the job is added as a background process.
Provides progress reports when available:
=over 4
=item * by calling C<$self-E<gt>set_progress($numerator, $denominator)>
=back
C<die()>s on error.
( run in 0.523 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )