Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/daemon/workers/action/PhabricatorScheduleTaskTriggerAction.php
12242 views
1
<?php
2
3
/**
4
* Trigger action which queues a task.
5
*
6
* Most triggers should take this action: triggers need to execute as quickly
7
* as possible, and should generally queue tasks instead of doing any real
8
* work.
9
*
10
* In some cases, triggers could execute more quickly by examining the
11
* scheduled action time and comparing it to the current time, then exiting
12
* early if the trigger is executing too far away from real time (for example,
13
* it might not make sense to send a meeting reminder after a meeting already
14
* happened).
15
*
16
* However, in most cases the task needs to have this logic anyway (because
17
* there may be another arbitrarily long delay between when this code executes
18
* and when the task executes), and the cost of queueing a task is very small,
19
* and situations where triggers are executing far away from real time should
20
* be rare (major downtime or serious problems with the pipeline).
21
*
22
* The properties of this action map to the parameters of
23
* @{method:PhabricatorWorker::scheduleTask}.
24
*/
25
final class PhabricatorScheduleTaskTriggerAction
26
extends PhabricatorTriggerAction {
27
28
public function validateProperties(array $properties) {
29
PhutilTypeSpec::checkMap(
30
$properties,
31
array(
32
'class' => 'string',
33
'data' => 'map<string, wild>',
34
'options' => 'map<string, wild>',
35
));
36
}
37
38
public function execute($last_epoch, $this_epoch) {
39
PhabricatorWorker::scheduleTask(
40
$this->getProperty('class'),
41
$this->getProperty('data') + array(
42
'trigger.last-epoch' => $last_epoch,
43
'trigger.this-epoch' => $this_epoch,
44
),
45
$this->getProperty('options'));
46
}
47
48
}
49
50