C4::BackgroundJob - manage long-running jobs initiated from the web staff interface
# start tracking a job my $job = C4::BackgroundJob->new($sessionID, $job_name, $job_invoker, $num_work_units); my $jobID = $job->id(); $job->progress($work_units_processed); $job->finish($job_result_hashref); # get status and results of a job my $job = C4::BackgroundJob->fetch($sessionID, $jobID); my $max_work_units = $job->size(); my $work_units_processed = $job->progress(); my $job_status = $job->status(); my $job_name = $job->name(); my $job_invoker = $job->invoker(); my $results_hashref = $job->results();
This module manages tracking the progress and results of (potentially) long-running jobs initiated from the staff user interface. Such jobs can include batch MARC and patron record imports.
my $job = C4::BackgroundJob->new($sessionID, $job_name, $job_invoker, $num_work_units);
Create a new job object and set its status to 'running'. $num_work_units
should be a number representing the size of the job; the units of the job size are up to the caller and could be number of records, number of bytes, etc.
my $jobID = $job->id();
Read-only accessor for job ID.
my $name = $job->name(); $job->name($name);
Read/write accessor for job name.
my $invoker = $job->invoker(); i $job->invoker($invoker);
Read/write accessor for job invoker.
my $progress = $job->progress(); $job->progress($progress);
Read/write accessor for job progress.
my $status = $job->status();
Read-only accessor for job status.
my $size = $job->size(); $job->size($size);
Read/write accessor for job size.
$job->finish($results_hashref);
Mark the job as finished, setting its status to 'completed'. $results_hashref
should be a reference to a hash containing the results of the job.
my $results_hashref = $job->results();
Retrieve the results of the current job. Returns undef if the job status is not 'completed'.
my $job = C4::BackgroundJob->fetch($sessionID, $jobID);
Retrieve a job that has been serialized to the database. Returns undef
if the job does not exist in the current session.
Set some variables into the hashref. These variables can be retrieved using the get method.
Get a variable which has been previously stored with the set method.
Koha Development Team <http://koha-community.org/>
Galen Charlton <galen.charlton@liblime.com>