2024-01-04 13:00:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Platform\Tasks;
|
|
|
|
|
|
|
|
|
|
use Utopia\CLI\Console;
|
|
|
|
|
use Utopia\Platform\Action;
|
|
|
|
|
use Utopia\Queue\Client;
|
|
|
|
|
use Utopia\Queue\Connection;
|
|
|
|
|
use Utopia\Validator\Text;
|
|
|
|
|
|
|
|
|
|
class Retry extends Action
|
|
|
|
|
{
|
|
|
|
|
public static function getName(): string
|
|
|
|
|
{
|
|
|
|
|
return 'retry';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this
|
|
|
|
|
->desc('Retry Queue')
|
|
|
|
|
->param('name', '', new Text(128), 'Queue name')
|
|
|
|
|
->inject('queue')
|
|
|
|
|
->callback(fn ($queueName, $queue) => $this->action($queueName, $queue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function action(string $queueName, Connection $queue): void
|
|
|
|
|
{
|
|
|
|
|
$queueClient = new Client($queueName, $queue);
|
|
|
|
|
|
|
|
|
|
if ($queueClient->sumFailedJobs() === 0) {
|
2024-01-05 12:37:03 +00:00
|
|
|
Console::error('No failed jobs found.');
|
2024-01-04 13:00:25 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$queueClient->retry();
|
|
|
|
|
}
|
2024-01-04 13:04:51 +00:00
|
|
|
}
|