<<

NAME

C4::BackgroundJob - manage long-running jobs initiated from the web staff interface

SYNOPSIS

 # 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.

METHODS

new

 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.

id

 my $jobID = $job->id();

Read-only accessor for job ID.

name

 my $name = $job->name();
 $job->name($name);

Read/write accessor for job name.

invoker

 my $invoker = $job->invoker();
i $job->invoker($invoker);

Read/write accessor for job invoker.

progress

 my $progress = $job->progress();
 $job->progress($progress);

Read/write accessor for job progress.

status

 my $status = $job->status();

Read-only accessor for job status.

size

 my $size = $job->size();
 $job->size($size);

Read/write accessor for job size.

finish

 $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.

results

 my $results_hashref = $job->results();

Retrieve the results of the current job. Returns undef if the job status is not 'completed'.

fetch

 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.

AUTHOR

Koha Development Team <http://koha-community.org/>

Galen Charlton <galen.charlton@liblime.com>

<<