Page MenuHomePhabricator
Diviner Phabricator Tech Docs PhabricatorSubscriptionTriggerClock

final class PhabricatorSubscriptionTriggerClock
Phabricator Technical Documentation (Daemons)

Triggers an event every month on the same day of the month, like the 12th of the month.

If a given month does not have such a day (for instance, the clock triggers on the 30th of each month and the month in question is February, which never has a 30th day), it will trigger on the last day of the month instead.

Choosing this strategy for subscriptions is predictable (it's easy to anticipate when a subscription period will end) and fair (billing periods always have nearly equal length). It also spreads subscriptions out evenly. If there are issues with billing, this provides an opportunity for them to be corrected after only a few customers are affected, instead of (for example) having every subscription fail all at once on the 1st of the month.

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)

PhabricatorTriggerClock

Validate clock configuration.

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

public function getNextEventEpoch($last_epoch, $is_reschedule)

PhabricatorTriggerClock

Get the next occurrence of this event.

This method takes two parameters: the last time this event occurred (or null if it has never triggered before) and a flag distinguishing between a normal reschedule (after a successful trigger) or an update because of a trigger change.

If this event does not occur again, return null to stop it from being rescheduled. For example, a meeting reminder may be sent only once before the meeting.

If this event does occur again, return the epoch timestamp of the next occurrence.

When performing routine reschedules, the event must move forward in time: any timestamp you return must be later than the last event. For instance, if this event triggers an invoice, the next invoice date must be after the previous invoice date. This prevents an event from looping more than once per second.

In contrast, after an update (not a routine reschedule), the next event may be scheduled at any time. For example, if a meeting is moved from next week to 3 minutes from now, the clock may reschedule the notification to occur 12 minutes ago. This will cause it to execute immediately.

PhabricatorSubscriptionTriggerClock
This method is not documented.
Parameters
int|null$last_epochLast time the event occurred, or null if it has never triggered before.
bool$is_rescheduleTrue if this is a reschedule after a successful trigger.
Return
int|nullNext event, or null to decline to reschedule.