mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
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
This commit is contained in:
parent
4cf1270ecd
commit
de2bbfef7d
2 changed files with 15 additions and 12 deletions
|
@ -160,8 +160,7 @@ abstract class PhabricatorWorker extends Phobject {
|
||||||
try {
|
try {
|
||||||
$worker->doWork();
|
$worker->doWork();
|
||||||
foreach ($worker->getQueuedTasks() as $queued_task) {
|
foreach ($worker->getQueuedTasks() as $queued_task) {
|
||||||
list($queued_class, $queued_data, $queued_priority) = $queued_task;
|
list($queued_class, $queued_data, $queued_options) = $queued_task;
|
||||||
$queued_options = array('priority' => $queued_priority);
|
|
||||||
self::scheduleTask($queued_class, $queued_data, $queued_options);
|
self::scheduleTask($queued_class, $queued_data, $queued_options);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -220,11 +219,14 @@ abstract class PhabricatorWorker extends Phobject {
|
||||||
*
|
*
|
||||||
* @param string Task class to queue.
|
* @param string Task class to queue.
|
||||||
* @param array Data for the followup task.
|
* @param array Data for the followup task.
|
||||||
* @param int|null Priority for the followup task.
|
* @param array Options for the followup task.
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
final protected function queueTask($class, array $data, $priority = null) {
|
final protected function queueTask(
|
||||||
$this->queuedTasks[] = array($class, $data, $priority);
|
$class,
|
||||||
|
array $data,
|
||||||
|
array $options = array()) {
|
||||||
|
$this->queuedTasks[] = array($class, $data, $options);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,13 +217,14 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
|
||||||
// so execute it out here and just let the exception escape.
|
// so execute it out here and just let the exception escape.
|
||||||
if ($did_succeed) {
|
if ($did_succeed) {
|
||||||
foreach ($worker->getQueuedTasks() as $task) {
|
foreach ($worker->getQueuedTasks() as $task) {
|
||||||
list($class, $data) = $task;
|
list($class, $data, $options) = $task;
|
||||||
PhabricatorWorker::scheduleTask(
|
|
||||||
$class,
|
// Default the new task priority to our own priority.
|
||||||
$data,
|
$options = $options + array(
|
||||||
array(
|
'priority' => (int)$this->getPriority(),
|
||||||
'priority' => (int)$this->getPriority(),
|
);
|
||||||
));
|
|
||||||
|
PhabricatorWorker::scheduleTask($class, $data, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue