Page MenuHomeIsabelle/Phabricator
Diviner Phabricator Tech Docs PhabricatorScheduleTaskTriggerAction

final class PhabricatorScheduleTaskTriggerAction
Phabricator Technical Documentation (Daemons)

Trigger action which queues a task.

Most triggers should take this action: triggers need to execute as quickly as possible, and should generally queue tasks instead of doing any real work.

In some cases, triggers could execute more quickly by examining the scheduled action time and comparing it to the current time, then exiting early if the trigger is executing too far away from real time (for example, it might not make sense to send a meeting reminder after a meeting already happened).

However, in most cases the task needs to have this logic anyway (because there may be another arbitrarily long delay between when this code executes and when the task executes), and the cost of queueing a task is very small, and situations where triggers are executing far away from real time should be rare (major downtime or serious problems with the pipeline).

The properties of this action map to the parameters of PhabricatorWorker::scheduleTask().

Methods

public function __construct($properties)
Inherited

This method is not documented.
Parameters
array$properties
Return
this//Implicit.//

public function getProperties()
Inherited

This method is not documented.
Return
wild

public function getProperty($key, $default)
Inherited

This method is not documented.
Parameters
$key
$default
Return
wild

public function validateProperties($properties)

PhabricatorTriggerAction

Validate action configuration.

PhabricatorScheduleTaskTriggerAction
This method is not documented.
Parameters
map<string,$propertieswild> Map of action properties.
Return
void

public function execute($last_epoch, $this_epoch)

PhabricatorTriggerAction

Execute this action.

IMPORTANT: Trigger actions must execute quickly!

In most cases, trigger actions should queue a worker task and then exit. The actual trigger execution occurs in a locked section in the trigger daemon and blocks all other triggers. By queueing a task instead of performing processing directly, triggers can execute more involved actions without blocking other triggers.

Almost all events should use PhabricatorScheduleTaskTriggerAction to do this, ensuring that they execute quickly.

An action may trigger a long time after it is scheduled. For example, a meeting reminder may be scheduled at 9:45 AM, but the action may not execute until later (for example, because the server was down for maintenance). You can detect cases like this by comparing $this_epoch (which holds the time the event was scheduled to execute at) to PhabricatorTime::getNow() (which returns the current time). In the case of a meeting reminder, you may want to ignore the action if it executes too late to be useful (for example, after a meeting is over).

Because actions should normally queue a task and there may be a second, arbitrarily long delay between trigger execution and task execution, it may be simplest to pass the trigger time to the task and then make the decision to discard the action there.

PhabricatorScheduleTaskTriggerAction
This method is not documented.
Parameters
int|null$last_epochLast time the event occurred, or null if it has never triggered before.
int$this_epochThe scheduled time for the current action. This may be significantly different from the current time.
Return
void