/**
* Defers the current worker entry
*
+ * @param int $worker_defer_limit Maximum defer limit
* @return boolean had the entry been deferred?
* @throws \Exception
*/
- public static function defer(): bool
+ public static function defer(int $worker_defer_limit = 0): bool
{
$queue = DI::app()->getQueue();
$max_level = DI::config()->get('system', 'worker_defer_limit');
+ if ($worker_defer_limit) {
+ $max_level = min($worker_defer_limit, $max_level);
+ }
+
$new_retrial = self::getNextRetrial($queue, $max_level);
if ($new_retrial > $max_level) {
class RevokeFollow
{
+ const WORKER_DEFER_LIMIT = 5;
+
/**
* Issue asynchronous follow revocation message to remote servers.
* The local relationship has already been updated, so we can't use the user-specific contact
}
if (!Protocol::revokeFollow($contact, $owner)) {
- Worker::defer();
+ Worker::defer(self::WORKER_DEFER_LIMIT);
}
}
}
class Unfollow
{
+ const WORKER_DEFER_LIMIT = 5;
+
/**
* Issue asynchronous unfollow message to remote servers.
* The local relationship has already been updated, so we can't use the user-specific contact.
$result = Protocol::unfollow($contact, $owner);
if ($result === false) {
- Worker::defer();
+ Worker::defer(self::WORKER_DEFER_LIMIT);
}
}
}
class FetchMissingActivity
{
+ const WORKER_DEFER_LIMIT = 5;
+
/**
* Fetch missing activities
* @param string $url Contact URL
$result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion);
if ($result) {
Logger::info('Successfully fetched missing activity', ['url' => $url]);
- } elseif (!Worker::defer()) {
+ } elseif (!Worker::defer(self::WORKER_DEFER_LIMIT)) {
Logger::info('Activity could not be fetched', ['url' => $url]);
// recursively delete all entries that belong to this worker task