diff --git a/composer.json b/composer.json index 9d0e34ac27..9a26b92506 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/platform": "0.5.*", "utopia-php/pools": "0.4.*", "utopia-php/preloader": "0.2.*", - "utopia-php/queue": "dev-feat-retry", + "utopia-php/queue": "0.7.*", "utopia-php/registry": "0.5.*", "utopia-php/storage": "0.18.*", "utopia-php/swoole": "0.5.*", @@ -82,10 +82,6 @@ { "url": "https://github.com/appwrite/runtimes.git", "type": "git" - }, - { - "url": "https://github.com/utopia-php/queue.git", - "type": "git" } ], "require-dev": { diff --git a/composer.lock b/composer.lock index 8106c5dc1b..f64f2d2b22 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "6ffcf14db0d3b00a5e85967a6deae4be", + "content-hash": "1f9bea9625c3f7b6421b60f4767f5bb6", "packages": [ { "name": "adhocore/jwt", @@ -277,16 +277,16 @@ }, { "name": "chillerlan/php-settings-container", - "version": "2.1.4", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a" + "reference": "f705310389264c3578fdd9ffb15aa2cd6d91772e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", - "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/f705310389264c3578fdd9ffb15aa2cd6d91772e", + "reference": "f705310389264c3578fdd9ffb15aa2cd6d91772e", "shasum": "" }, "require": { @@ -294,8 +294,10 @@ "php": "^7.4 || ^8.0" }, "require-dev": { - "phan/phan": "^5.3", - "phpunit/phpunit": "^9.5" + "phan/phan": "^5.4", + "phpcsstandards/php_codesniffer": "^3.8", + "phpmd/phpmd": "^2.13", + "phpunit/phpunit": "^9.6" }, "type": "library", "autoload": { @@ -337,7 +339,7 @@ "type": "ko_fi" } ], - "time": "2022-07-05T22:32:14+00:00" + "time": "2024-01-05T23:20:55+00:00" }, { "name": "dragonmantank/cron-expression", @@ -2072,12 +2074,12 @@ "version": "0.31.1", "source": { "type": "git", - "url": "https://github.com/utopia-php/framework.git", + "url": "https://github.com/utopia-php/http.git", "reference": "e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68", + "url": "https://api.github.com/repos/utopia-php/http/zipball/e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68", "reference": "e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68", "shasum": "" }, @@ -2107,8 +2109,8 @@ "upf" ], "support": { - "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.31.1" + "issues": "https://github.com/utopia-php/http/issues", + "source": "https://github.com/utopia-php/http/tree/0.31.1" }, "time": "2023-12-08T18:47:29+00:00" }, @@ -2629,11 +2631,17 @@ }, { "name": "utopia-php/queue", - "version": "dev-feat-retry", + "version": "0.7.0", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "9930184b3e9f5c92b5298763968f4b1d92fbe6e2" + "reference": "917565256eb94bcab7246f7a746b1a486813761b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/917565256eb94bcab7246f7a746b1a486813761b", + "reference": "917565256eb94bcab7246f7a746b1a486813761b", + "shasum": "" }, "require": { "php": ">=8.0", @@ -2657,25 +2665,7 @@ "Utopia\\Queue\\": "src/Queue" } }, - "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" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2687,14 +2677,18 @@ ], "description": "A powerful task queue.", "keywords": [ + "Tasks", "framework", "php", "queue", - "tasks", "upf", "utopia" ], - "time": "2023-12-29T15:06:54+00:00" + "support": { + "issues": "https://github.com/utopia-php/queue/issues", + "source": "https://github.com/utopia-php/queue/tree/0.7.0" + }, + "time": "2024-01-17T19:00:43+00:00" }, { "name": "utopia-php/registry", @@ -3144,16 +3138,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.36.0", + "version": "0.36.1", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a" + "reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3a10f1f895ed71120442ff71eb6adec3fd6b4e8a", - "reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992", + "reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992", "shasum": "" }, "require": { @@ -3189,9 +3183,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.36.0" + "source": "https://github.com/appwrite/sdk-generator/tree/0.36.1" }, - "time": "2023-11-20T10:03:06+00:00" + "time": "2024-01-18T06:24:47+00:00" }, { "name": "doctrine/deprecations", @@ -3495,25 +3489,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -3521,7 +3517,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -3545,9 +3541,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-01-07T17:17:35+00:00" }, { "name": "phar-io/manifest", @@ -3772,16 +3768,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", "shasum": "" }, "require": { @@ -3824,9 +3820,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-01-11T11:49:22+00:00" }, { "name": "phpspec/prophecy", @@ -3899,16 +3895,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.5", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", "shasum": "" }, "require": { @@ -3940,9 +3936,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" }, - "time": "2023-12-16T09:33:33+00:00" + "time": "2024-01-04T17:06:16+00:00" }, { "name": "phpunit/php-code-coverage", @@ -5382,16 +5378,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.0", + "version": "3.8.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", - "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", "shasum": "" }, "require": { @@ -5401,11 +5397,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -5458,7 +5454,7 @@ "type": "open_collective" } ], - "time": "2023-12-08T12:32:31+00:00" + "time": "2024-01-11T20:47:48+00:00" }, { "name": "swoole/ide-helper", @@ -5831,9 +5827,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/queue": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Tasks/Retry.php b/src/Appwrite/Platform/Tasks/Retry.php index 9e8f28ab78..d78e309bba 100644 --- a/src/Appwrite/Platform/Tasks/Retry.php +++ b/src/Appwrite/Platform/Tasks/Retry.php @@ -12,24 +12,33 @@ class Retry extends Action { public static function getName(): string { - return 'retry'; + return 'retry-jobs'; } public function __construct() { $this - ->desc('Retry Queue') + ->desc('Retry failed jobs from a specific queue identified by the name parameter') ->param('name', '', new Text(128), 'Queue name') ->inject('queue') - ->callback(fn ($queueName, $queue) => $this->action($queueName, $queue)); + ->callback(fn ($name, $queue) => $this->action($name, $queue)); } - public function action(string $queueName, Connection $queue): void + /** + * @param string $name The name of the queue to retry jobs from + * @param Connection $queue + */ + public function action(string $name, Connection $queue): void { - $queueClient = new Client($queueName, $queue); + if (!$name) { + Console::error('Missing required parameter $name'); + return; + } - if ($queueClient->sumFailedJobs() === 0) { + $queueClient = new Client($name, $queue); + + if ($queueClient->countFailedJobs() === 0) { Console::error('No failed jobs found.'); return; }