Path: blob/master/src/infrastructure/daemon/workers/action/PhabricatorScheduleTaskTriggerAction.php
12242 views
<?php12/**3* Trigger action which queues a task.4*5* Most triggers should take this action: triggers need to execute as quickly6* as possible, and should generally queue tasks instead of doing any real7* work.8*9* In some cases, triggers could execute more quickly by examining the10* scheduled action time and comparing it to the current time, then exiting11* early if the trigger is executing too far away from real time (for example,12* it might not make sense to send a meeting reminder after a meeting already13* happened).14*15* However, in most cases the task needs to have this logic anyway (because16* there may be another arbitrarily long delay between when this code executes17* and when the task executes), and the cost of queueing a task is very small,18* and situations where triggers are executing far away from real time should19* be rare (major downtime or serious problems with the pipeline).20*21* The properties of this action map to the parameters of22* @{method:PhabricatorWorker::scheduleTask}.23*/24final class PhabricatorScheduleTaskTriggerAction25extends PhabricatorTriggerAction {2627public function validateProperties(array $properties) {28PhutilTypeSpec::checkMap(29$properties,30array(31'class' => 'string',32'data' => 'map<string, wild>',33'options' => 'map<string, wild>',34));35}3637public function execute($last_epoch, $this_epoch) {38PhabricatorWorker::scheduleTask(39$this->getProperty('class'),40$this->getProperty('data') + array(41'trigger.last-epoch' => $last_epoch,42'trigger.this-epoch' => $this_epoch,43),44$this->getProperty('options'));45}4647}484950