Add Queue Retry Command to Appwrite
This commit is contained in:
parent
3236e9eabe
commit
01d76a1746
6 changed files with 77 additions and 18 deletions
|
@ -85,6 +85,7 @@ RUN chmod +x /usr/local/bin/doctor && \
|
|||
chmod +x /usr/local/bin/ssl && \
|
||||
chmod +x /usr/local/bin/test && \
|
||||
chmod +x /usr/local/bin/vars && \
|
||||
chmod +x /usr/local/bin/retry && \
|
||||
chmod +x /usr/local/bin/worker-audits && \
|
||||
chmod +x /usr/local/bin/worker-certificates && \
|
||||
chmod +x /usr/local/bin/worker-databases && \
|
||||
|
|
3
bin/retry
Normal file
3
bin/retry
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php retry $@
|
|
@ -62,7 +62,7 @@
|
|||
"utopia-php/platform": "0.5.*",
|
||||
"utopia-php/pools": "0.4.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
"utopia-php/queue": "0.5.*",
|
||||
"utopia-php/queue": "dev-feat-retry",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/storage": "0.18.*",
|
||||
"utopia-php/swoole": "0.5.*",
|
||||
|
@ -82,6 +82,10 @@
|
|||
{
|
||||
"url": "https://github.com/appwrite/runtimes.git",
|
||||
"type": "git"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/utopia-php/queue.git",
|
||||
"type": "git"
|
||||
}
|
||||
],
|
||||
"require-dev": {
|
||||
|
|
44
composer.lock
generated
44
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7041499af2e7b23795d8ef82c9d7a072",
|
||||
"content-hash": "6ffcf14db0d3b00a5e85967a6deae4be",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -2629,17 +2629,11 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/queue",
|
||||
"version": "0.5.3",
|
||||
"version": "dev-feat-retry",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/queue.git",
|
||||
"reference": "8e8b6cb27172713fe5d8b7b092ce68516caf129a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/queue/zipball/8e8b6cb27172713fe5d8b7b092ce68516caf129a",
|
||||
"reference": "8e8b6cb27172713fe5d8b7b092ce68516caf129a",
|
||||
"shasum": ""
|
||||
"reference": "9930184b3e9f5c92b5298763968f4b1d92fbe6e2"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
|
@ -2663,7 +2657,25 @@
|
|||
"Utopia\\Queue\\": "src/Queue"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\E2E\\": "tests/Queue/E2E"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"phpunit"
|
||||
],
|
||||
"analyse": [
|
||||
"vendor/bin/phpstan analyse"
|
||||
],
|
||||
"format": [
|
||||
"vendor/bin/pint"
|
||||
],
|
||||
"lint": [
|
||||
"vendor/bin/pint --test"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
|
@ -2675,18 +2687,14 @@
|
|||
],
|
||||
"description": "A powerful task queue.",
|
||||
"keywords": [
|
||||
"Tasks",
|
||||
"framework",
|
||||
"php",
|
||||
"queue",
|
||||
"tasks",
|
||||
"upf",
|
||||
"utopia"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/queue/issues",
|
||||
"source": "https://github.com/utopia-php/queue/tree/0.5.3"
|
||||
},
|
||||
"time": "2023-05-24T19:06:04+00:00"
|
||||
"time": "2023-12-29T15:06:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/registry",
|
||||
|
@ -5823,7 +5831,9 @@
|
|||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"utopia-php/queue": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
|
|
@ -21,6 +21,7 @@ use Appwrite\Platform\Tasks\Upgrade;
|
|||
use Appwrite\Platform\Tasks\DeleteOrphanedProjects;
|
||||
use Appwrite\Platform\Tasks\GetMigrationStats;
|
||||
use Appwrite\Platform\Tasks\PatchRecreateRepositoriesDocuments;
|
||||
use Appwrite\Platform\Tasks\Retry;
|
||||
|
||||
class Tasks extends Service
|
||||
{
|
||||
|
@ -46,6 +47,7 @@ class Tasks extends Service
|
|||
->addAction(DeleteOrphanedProjects::getName(), new DeleteOrphanedProjects())
|
||||
->addAction(PatchRecreateRepositoriesDocuments::getName(), new PatchRecreateRepositoriesDocuments())
|
||||
->addAction(GetMigrationStats::getName(), new GetMigrationStats())
|
||||
->addAction(Retry::getName(), new Retry())
|
||||
|
||||
;
|
||||
}
|
||||
|
|
39
src/Appwrite/Platform/Tasks/Retry.php
Normal file
39
src/Appwrite/Platform/Tasks/Retry.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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) {
|
||||
Console::error('Found no jobs to retry, are you sure you have the right queue name?');
|
||||
return;
|
||||
}
|
||||
|
||||
$queueClient->retry();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue