Individual defer limits per worker task
This commit is contained in:
parent
a7c985a590
commit
9faad72ec0
4 changed files with 15 additions and 4 deletions
|
@ -1379,10 +1379,11 @@ class Worker
|
|||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -1395,6 +1396,10 @@ class Worker
|
|||
|
||||
$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) {
|
||||
|
|
|
@ -29,6 +29,8 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
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
|
||||
|
@ -51,7 +53,7 @@ class RevokeFollow
|
|||
}
|
||||
|
||||
if (!Protocol::revokeFollow($contact, $owner)) {
|
||||
Worker::defer();
|
||||
Worker::defer(self::WORKER_DEFER_LIMIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ use Friendica\Model\User;
|
|||
|
||||
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.
|
||||
|
@ -51,7 +53,7 @@ class Unfollow
|
|||
|
||||
$result = Protocol::unfollow($contact, $owner);
|
||||
if ($result === false) {
|
||||
Worker::defer();
|
||||
Worker::defer(self::WORKER_DEFER_LIMIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ use Friendica\Protocol\ActivityPub\Receiver;
|
|||
|
||||
class FetchMissingActivity
|
||||
{
|
||||
const WORKER_DEFER_LIMIT = 5;
|
||||
|
||||
/**
|
||||
* Fetch missing activities
|
||||
* @param string $url Contact URL
|
||||
|
@ -42,7 +44,7 @@ class FetchMissingActivity
|
|||
$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
|
||||
|
|
Loading…
Reference in a new issue