From de2bbfef7d147e1ef6903392778a1415cd58a874 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 5 Oct 2015 09:46:29 -0700 Subject: [PATCH] Allow PhabricatorWorker->queueTask() to take full $options Summary: Ref T9252. Currently, `queueTask()` accepts `$priority` as its third argument. Allow it to take a full range of `$options` instead. This API just never got updated after we expanded avialable options. Arguably this whole API should be some kind of "TaskQueueRequest" object but I'll leave that for another day. Test Plan: - Grepped for `queueTask()` and verified no other callsites are affected by this API change. - Ran some daemons. - See also next diff. Reviewers: hach-que, chad Reviewed By: hach-que, chad Maniphest Tasks: T9252 Differential Revision: https://secure.phabricator.com/D14235 --- .../daemon/workers/PhabricatorWorker.php | 12 +++++++----- .../storage/PhabricatorWorkerActiveTask.php | 15 ++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/infrastructure/daemon/workers/PhabricatorWorker.php b/src/infrastructure/daemon/workers/PhabricatorWorker.php index c448e7221a..473649ba19 100644 --- a/src/infrastructure/daemon/workers/PhabricatorWorker.php +++ b/src/infrastructure/daemon/workers/PhabricatorWorker.php @@ -160,8 +160,7 @@ abstract class PhabricatorWorker extends Phobject { try { $worker->doWork(); foreach ($worker->getQueuedTasks() as $queued_task) { - list($queued_class, $queued_data, $queued_priority) = $queued_task; - $queued_options = array('priority' => $queued_priority); + list($queued_class, $queued_data, $queued_options) = $queued_task; self::scheduleTask($queued_class, $queued_data, $queued_options); } break; @@ -220,11 +219,14 @@ abstract class PhabricatorWorker extends Phobject { * * @param string Task class to queue. * @param array Data for the followup task. - * @param int|null Priority for the followup task. + * @param array Options for the followup task. * @return this */ - final protected function queueTask($class, array $data, $priority = null) { - $this->queuedTasks[] = array($class, $data, $priority); + final protected function queueTask( + $class, + array $data, + array $options = array()) { + $this->queuedTasks[] = array($class, $data, $options); return $this; } diff --git a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php index 6c2f5b4461..57a1794ec3 100644 --- a/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php +++ b/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php @@ -217,13 +217,14 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask { // so execute it out here and just let the exception escape. if ($did_succeed) { foreach ($worker->getQueuedTasks() as $task) { - list($class, $data) = $task; - PhabricatorWorker::scheduleTask( - $class, - $data, - array( - 'priority' => (int)$this->getPriority(), - )); + list($class, $data, $options) = $task; + + // Default the new task priority to our own priority. + $options = $options + array( + 'priority' => (int)$this->getPriority(), + ); + + PhabricatorWorker::scheduleTask($class, $data, $options); } } -- 2.51.2