mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Add support for a "containerPHID" in the worker queue
Summary: Ref T13591. Worker queue tasks which affect commits currently (mostly) store the commit as an "objectPHID", but do not directly reference the repository the commit belongs to. This can make certain operations (like "change the priority of all tasks affecting repository Y") more difficult than it needs to be. Support a "containerPHID", similar to the field of the same name on builds, that can store a parent object like a repository and better support operations against subsets of tasks. See also D11044 for the genesis of "objectPHID". This depends on the introduction of storage patch phases (in D21529) so that earlier migrations which queue worker tasks don't try to insert this column before it actually exists. Test Plan: - Ran `bin/storage upgrade`. - No callers yet, see further changes for usage. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13591 Differential Revision: https://secure.phabricator.com/D21531
This commit is contained in:
parent
32942f6232
commit
201e0d2943
5 changed files with 16 additions and 1 deletions
5
resources/sql/autopatches/20210122.queuecontainer.01.sql
Normal file
5
resources/sql/autopatches/20210122.queuecontainer.01.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE {$NAMESPACE}_worker.worker_activetask
|
||||
ADD containerPHID VARBINARY(64);
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_worker.worker_archivetask
|
||||
ADD containerPHID VARBINARY(64);
|
|
@ -134,6 +134,7 @@ abstract class PhabricatorWorker extends Phobject {
|
|||
array(
|
||||
'priority' => 'optional int|null',
|
||||
'objectPHID' => 'optional string|null',
|
||||
'containerPHID' => 'optional string|null',
|
||||
'delayUntil' => 'optional int|null',
|
||||
));
|
||||
|
||||
|
@ -142,12 +143,14 @@ abstract class PhabricatorWorker extends Phobject {
|
|||
$priority = self::PRIORITY_DEFAULT;
|
||||
}
|
||||
$object_phid = idx($options, 'objectPHID');
|
||||
$container_phid = idx($options, 'containerPHID');
|
||||
|
||||
$task = id(new PhabricatorWorkerActiveTask())
|
||||
->setTaskClass($task_class)
|
||||
->setData($data)
|
||||
->setPriority($priority)
|
||||
->setObjectPHID($object_phid);
|
||||
->setObjectPHID($object_phid)
|
||||
->setContainerPHID($container_phid);
|
||||
|
||||
$delay = idx($options, 'delayUntil');
|
||||
if ($delay) {
|
||||
|
|
|
@ -116,6 +116,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
|
|||
->setDataID($this->getDataID())
|
||||
->setPriority($this->getPriority())
|
||||
->setObjectPHID($this->getObjectPHID())
|
||||
->setContainerPHID($this->getContainerPHID())
|
||||
->setResult($result)
|
||||
->setDuration($duration)
|
||||
->setDateCreated($this->getDateCreated())
|
||||
|
|
|
@ -87,6 +87,7 @@ final class PhabricatorWorkerArchiveTask extends PhabricatorWorkerTask {
|
|||
->setDataID($this->getDataID())
|
||||
->setPriority($this->getPriority())
|
||||
->setObjectPHID($this->getObjectPHID())
|
||||
->setContainerPHID($this->getContainerPHID())
|
||||
->setDateCreated($this->getDateCreated())
|
||||
->insert();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ abstract class PhabricatorWorkerTask extends PhabricatorWorkerDAO {
|
|||
protected $dataID;
|
||||
protected $priority;
|
||||
protected $objectPHID;
|
||||
protected $containerPHID;
|
||||
|
||||
private $data;
|
||||
private $executionException;
|
||||
|
@ -25,11 +26,15 @@ abstract class PhabricatorWorkerTask extends PhabricatorWorkerDAO {
|
|||
'failureTime' => 'epoch?',
|
||||
'priority' => 'uint32',
|
||||
'objectPHID' => 'phid?',
|
||||
'containerPHID' => 'phid?',
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
'key_object' => array(
|
||||
'columns' => array('objectPHID'),
|
||||
),
|
||||
'key_container' => array(
|
||||
'columns' => array('containerPHID'),
|
||||
),
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue