summaryrefslogtreecommitdiffstats
path: root/Bugzilla/JobQueue.pm
diff options
context:
space:
mode:
authorGervase Markham <gerv@gerv.net>2012-04-11 10:37:07 +0200
committerGervase Markham <gerv@mozilla.org>2012-04-11 10:37:07 +0200
commit6a83a1dd95d39a9a438ed105daf29c3f42218435 (patch)
treee35656df2e5465b25cb2b022fbc72e58e72a6576 /Bugzilla/JobQueue.pm
parentb4fee2c33267420765ed2bf15a639a5d36d35fc5 (diff)
downloadbugzilla-6a83a1dd95d39a9a438ed105daf29c3f42218435.tar.gz
bugzilla-6a83a1dd95d39a9a438ed105daf29c3f42218435.tar.xz
Bug 706412 - make JobQueue.pm support insertion of Job objects, and also enable prioritization. r,a=LpSolit.
Diffstat (limited to 'Bugzilla/JobQueue.pm')
-rw-r--r--Bugzilla/JobQueue.pm18
1 files changed, 13 insertions, 5 deletions
diff --git a/Bugzilla/JobQueue.pm b/Bugzilla/JobQueue.pm
index ceea53809..f8bd6a615 100644
--- a/Bugzilla/JobQueue.pm
+++ b/Bugzilla/JobQueue.pm
@@ -53,6 +53,7 @@ sub new {
prefix => 'ts_',
}],
driver_cache_expiration => DRIVER_CACHE_TIME,
+ prioritize => 1,
);
return $self;
@@ -70,12 +71,19 @@ sub insert {
my $self = shift;
my $job = shift;
- my $mapped_job = Bugzilla::JobQueue->job_map()->{$job};
- ThrowCodeError('jobqueue_no_job_mapping', { job => $job })
- if !$mapped_job;
- unshift(@_, $mapped_job);
+ if (!ref($job)) {
+ my $mapped_job = Bugzilla::JobQueue->job_map()->{$job};
+ ThrowCodeError('jobqueue_no_job_mapping', { job => $job })
+ if !$mapped_job;
- my $retval = $self->SUPER::insert(@_);
+ $job = new TheSchwartz::Job(
+ funcname => $mapped_job,
+ arg => $_[0],
+ priority => $_[1] || 5
+ );
+ }
+
+ my $retval = $self->SUPER::insert($job);
# XXX Need to get an error message here if insert fails, but
# I don't see any way to do that in TheSchwartz.
ThrowCodeError('jobqueue_insert_failed', { job => $job, errmsg => $@ })