Koha::BackgroundJob - Koha BackgroundJob Object class
This is a base class for BackgroundJob, some methods must be subclassed.
Example of usage:
Producer: my $job_id = Koha::BackgroundJob->enqueue( { job_type => $job_type, job_size => $job_size, job_args => $job_args } );
Consumer: Koha::BackgroundJobs->find($job_id)->process; See also misc/background_jobs_worker.pl
for a full example
Connect to the message broker using default guest/guest credential
Enqueue a new job. It will insert a new row in the DB table and notify the broker that a new job has been enqueued.
job_size
is the size of the job job_args
is the arguments of the job.
It's a structure that will be JSON encoded.
Return the job_id of the newly created job.
Process the job!
$self->start;
Marks the job as started.
$self->step;
Makes the job record a step has taken place.
$self->finish;
Makes the job record as finished. If the job status is cancelled, it is kept.
my $JSON_object = $self->json;
Returns a JSON object with utf8 disabled. Encoding to UTF-8 should be done later.
my $job_data = $self->decoded_data;
Returns the decoded JSON contents from $self->data.
$self->set_encoded_data( $data );
Serializes $data as a JSON string and sets the data attribute with it.
Return the job type of the job. Must be a string.
Messages let during the processing of the job.
Report of the job.
Build additional variables for the job detail view.
Cancel a job.
my $mapping = Koha::BackgroundJob->new->type_to_class_mapping;
Returns the available types to class mappings.
my $mappings = Koha::BackgroundJob->new->core_types_to_classes
Returns the core background jobs types to class mappings.
my $mappings = Koha::BackgroundJob->new->plugin_types_to_classes
Returns the plugin-defined background jobs types to class mappings.
my $json = $job->to_api;
Overloaded method that returns a JSON representation of the Koha::BackgroundJob object, suitable for API output.
This method returns the mapping for representing a Koha::BackgroundJob object on the API.