@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "schedule task" trigger action

Summary: Ref T6881. Add a standard "just queue a task" trigger action; I expect almost all application code to use this.

Test Plan: Will test in Instances.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6881

Differential Revision: https://secure.phabricator.com/D11429

+54
+2
src/__phutil_library_map__.php
··· 2362 2362 'PhabricatorSSHWorkflow' => 'infrastructure/ssh/PhabricatorSSHWorkflow.php', 2363 2363 'PhabricatorSavedQuery' => 'applications/search/storage/PhabricatorSavedQuery.php', 2364 2364 'PhabricatorSavedQueryQuery' => 'applications/search/query/PhabricatorSavedQueryQuery.php', 2365 + 'PhabricatorScheduleTaskTriggerAction' => 'infrastructure/daemon/workers/action/PhabricatorScheduleTaskTriggerAction.php', 2365 2366 'PhabricatorScopedEnv' => 'infrastructure/env/PhabricatorScopedEnv.php', 2366 2367 'PhabricatorSearchAbstractDocument' => 'applications/search/index/PhabricatorSearchAbstractDocument.php', 2367 2368 'PhabricatorSearchApplication' => 'applications/search/application/PhabricatorSearchApplication.php', ··· 5643 5644 'PhabricatorPolicyInterface', 5644 5645 ), 5645 5646 'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5647 + 'PhabricatorScheduleTaskTriggerAction' => 'PhabricatorTriggerAction', 5646 5648 'PhabricatorSearchApplication' => 'PhabricatorApplication', 5647 5649 'PhabricatorSearchApplicationSearchEngine' => 'PhabricatorApplicationSearchEngine', 5648 5650 'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
+45
src/infrastructure/daemon/workers/action/PhabricatorScheduleTaskTriggerAction.php
··· 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'), 42 + $this->getProperty('options')); 43 + } 44 + 45 + }
+7
src/infrastructure/daemon/workers/action/PhabricatorTriggerAction.php
··· 2 2 3 3 /** 4 4 * A trigger action reacts to a scheduled event. 5 + * 6 + * Almost all events should use a @{class:PhabricatorScheduleTaskTriggerAction}. 7 + * Avoid introducing new actions without strong justification. See that class 8 + * for discussion of concerns. 5 9 */ 6 10 abstract class PhabricatorTriggerAction extends Phobject { 7 11 ··· 40 44 * daemon and blocks all other triggers. By queueing a task instead of 41 45 * performing processing directly, triggers can execute more involved actions 42 46 * without blocking other triggers. 47 + * 48 + * Almost all events should use @{class:PhabricatorScheduleTaskTriggerAction} 49 + * to do this, ensuring that they execute quickly. 43 50 * 44 51 * An action may trigger a long time after it is scheduled. For example, 45 52 * a meeting reminder may be scheduled at 9:45 AM, but the action may not