From 84f47dc1d218e234f3f55f6dad7ca4a6d91af71e Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 28 Feb 2024 20:21:35 +0200 Subject: [PATCH] adding limit to queue retry --- src/Appwrite/Platform/Tasks/QueueRetry.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/QueueRetry.php b/src/Appwrite/Platform/Tasks/QueueRetry.php index cba68f9936..bae5a59c45 100644 --- a/src/Appwrite/Platform/Tasks/QueueRetry.php +++ b/src/Appwrite/Platform/Tasks/QueueRetry.php @@ -7,6 +7,7 @@ use Utopia\CLI\Console; use Utopia\Platform\Action; use Utopia\Queue\Client; use Utopia\Queue\Connection; +use Utopia\Validator\Integer; use Utopia\Validator\WhiteList; class QueueRetry extends Action @@ -35,15 +36,17 @@ class QueueRetry extends Action Event::MIGRATIONS_QUEUE_NAME, Event::HAMSTER_CLASS_NAME ]), 'Queue name') + ->param('limit', 0, new Integer(true), 'jobs limit', true) ->inject('queue') - ->callback(fn ($name, $queue) => $this->action($name, $queue)); + ->callback(fn ($name, $limit, $queue) => $this->action($name, $limit, $queue)); } /** * @param string $name The name of the queue to retry jobs from + * @param int $limit * @param Connection $queue */ - public function action(string $name, Connection $queue): void + public function action(string $name, int $limit, Connection $queue): void { if (!$name) { Console::error('Missing required parameter $name'); @@ -59,6 +62,6 @@ class QueueRetry extends Action Console::log('Retrying failed jobs...'); - $queueClient->retry(); + $queueClient->retry($limit); } }