Analizo
view release on metacpan or search on metacpan
lib/Analizo/Batch/Runner.pm view on Meta::CPAN
package Analizo::Batch::Runner;
use parent qw(Class::Accessor::Fast);
sub new {
my ($class, @args) = @_;
return bless { @args }, $class;
}
sub run($$$) {
my ($self, $batch, $output) = @_;
$output->initialize();
$self->actually_run($batch, $output);
$output->flush();
}
# must be implemented by subclasses. Will receive as argument:
#
# * the batch to be run
# * the output object
#
# This method must iterate over the jobs in some way, depending on the strategy
# employed by the subclass, call I<execute> on each job, and feed the job
# object to the $output object by calling I<$output->push($job)>. In the end,
# the runner must call flush() on the output object.
sub actually_run {
}
__PACKAGE__->mk_accessors(qw( progress ));
sub report_progress {
my ($self, $job, $i, $n) = @_;
my $progress = $self->progress;
if ($progress) {
&$progress($job, $i, $n);
}
}
1;
( run in 2.833 seconds using v1.01-cache-2.11-cpan-524268b4103 )