Scroll to navigation

Tirex::Job(3pm) User Contributed Perl Documentation Tirex::Job(3pm)

NAME

Tirex::Job - A Tirex rendering job

SYNOPSIS

my $job = Tirex::Job->new( metatile => $metatile, prio => 5, expire => time() + 60*60 );

DESCRIPTION

Tirex jobs consist of a metatile, rendering priority and an expire time plus some optional additional info. They are created when rendering requests reach the master and put into the queue.

METHODS

Tirex::Job->new( ... )

Create new job.

A job always needs the following parameters:

 metatile -- the metatile
 prio     -- priority (integer >= 1, 1 is highest priority

It can have any or all of the following parameters:

 expire       -- the time when this job will expire (seconds since epoch)
 request_time -- the time when this request came in (seconds since epoch, will be set to current time if not set)

$job->same_tile($other_job)

Returns true if both jobs concern the same metatile, false otherwise.

The same tile means: same map, same x and y coordinates and same zoom level.

$job->expired()

Returns 1 if this job is expired, 0 otherwise.

If the job doesn't have an expire time, it returns undef;

$job->to_s( foo => 'bar' )

Creates a message string from the job. It contains the fields id, map, x, y, and z from the job plus all the fields given as argument to this method.

$job->to_msg( foo => 'bar' )

Creates a message from the job. It contains the fields id, map, x, y, z, prio from the job and, if available, the field priority.

All the fields given as argument to this method will also be added. You must give a type argument, otherwise this will croak.

$job->get_id()

Get unique id of this job.

$job->get_prio()

Get priority of this job.

$job->set_prio($prio)

Set priority of this job.

$job->get_metatile()

Get metatile of this job.

$job->get_pos()

Get position of this job in the priority queue. Returns undef if the job is in no queue.

$job->set_pos($pos)

Set position of this job in the priority queue. Set to undef if the job is in no queue.

$job->get_bucket()

Get bucket for this job.

$job->set_bucket($bucket)

Set bucket for this job.

$job->get_success()

Get success flag for this job.

$job->set_success($success)

Set success flag for this job.

$job->hash_key()

Create a hash key (string) from the contents of this job. Only the attributes describing the tile are included. So that this hash key is unique for any tile.

$job->merge($secondjob)

Merge two jobs for the same metatile into one. This method will look into both jobs and create a new job from the data. The old jobs are not changed.

 * priority of the new job will be the minimum of the priorities of the old jobs
 * expire will be the maximum of the expire times of the old jobs, if there is no expire time for at least one job, the result will have no expire time either
 * notify will be the concatenation of both notifies
 * request_time will be the minimum of both request times

This methods assumes that the metatiles are the same, it does no check.

$job->add_notify($source)

Add a Tirex::Source to be notified when this job is done.

$job->has_notify()

Returns true if any sources are waiting to be notified of this job's completion.

$job->notify()

Notify all sources that this job is done. Returns an array reference with the result of the notify calls on the sources.

Clears the notify list.

$job->sources_as_string()

The sources of this job as a string (for logging).

$job->age()

Returns age of this job in seconds (ie. the difference between current and request time).

2021-10-07 perl v5.32.1