Address Christy's Comments and Update Lib

This commit is contained in:
Bradley Schofield 2024-01-19 13:18:37 +00:00
parent da014b0ad3
commit 1e247bdde1
3 changed files with 83 additions and 84 deletions

View file

@ -62,7 +62,7 @@
"utopia-php/platform": "0.5.*", "utopia-php/platform": "0.5.*",
"utopia-php/pools": "0.4.*", "utopia-php/pools": "0.4.*",
"utopia-php/preloader": "0.2.*", "utopia-php/preloader": "0.2.*",
"utopia-php/queue": "dev-feat-retry", "utopia-php/queue": "0.7.*",
"utopia-php/registry": "0.5.*", "utopia-php/registry": "0.5.*",
"utopia-php/storage": "0.18.*", "utopia-php/storage": "0.18.*",
"utopia-php/swoole": "0.5.*", "utopia-php/swoole": "0.5.*",
@ -82,10 +82,6 @@
{ {
"url": "https://github.com/appwrite/runtimes.git", "url": "https://github.com/appwrite/runtimes.git",
"type": "git" "type": "git"
},
{
"url": "https://github.com/utopia-php/queue.git",
"type": "git"
} }
], ],
"require-dev": { "require-dev": {

140
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6ffcf14db0d3b00a5e85967a6deae4be", "content-hash": "1f9bea9625c3f7b6421b60f4767f5bb6",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@ -277,16 +277,16 @@
}, },
{ {
"name": "chillerlan/php-settings-container", "name": "chillerlan/php-settings-container",
"version": "2.1.4", "version": "2.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/chillerlan/php-settings-container.git", "url": "https://github.com/chillerlan/php-settings-container.git",
"reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a" "reference": "f705310389264c3578fdd9ffb15aa2cd6d91772e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/f705310389264c3578fdd9ffb15aa2cd6d91772e",
"reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", "reference": "f705310389264c3578fdd9ffb15aa2cd6d91772e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -294,8 +294,10 @@
"php": "^7.4 || ^8.0" "php": "^7.4 || ^8.0"
}, },
"require-dev": { "require-dev": {
"phan/phan": "^5.3", "phan/phan": "^5.4",
"phpunit/phpunit": "^9.5" "phpcsstandards/php_codesniffer": "^3.8",
"phpmd/phpmd": "^2.13",
"phpunit/phpunit": "^9.6"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -337,7 +339,7 @@
"type": "ko_fi" "type": "ko_fi"
} }
], ],
"time": "2022-07-05T22:32:14+00:00" "time": "2024-01-05T23:20:55+00:00"
}, },
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
@ -2072,12 +2074,12 @@
"version": "0.31.1", "version": "0.31.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/framework.git", "url": "https://github.com/utopia-php/http.git",
"reference": "e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68" "reference": "e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68"
}, },
"dist": { "dist": {
"type": "zip", "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", "reference": "e50d2d16f4bc31319043f3f6d3dbea36c6fd6b68",
"shasum": "" "shasum": ""
}, },
@ -2107,8 +2109,8 @@
"upf" "upf"
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/framework/issues", "issues": "https://github.com/utopia-php/http/issues",
"source": "https://github.com/utopia-php/framework/tree/0.31.1" "source": "https://github.com/utopia-php/http/tree/0.31.1"
}, },
"time": "2023-12-08T18:47:29+00:00" "time": "2023-12-08T18:47:29+00:00"
}, },
@ -2629,11 +2631,17 @@
}, },
{ {
"name": "utopia-php/queue", "name": "utopia-php/queue",
"version": "dev-feat-retry", "version": "0.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/queue.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": { "require": {
"php": ">=8.0", "php": ">=8.0",
@ -2657,25 +2665,7 @@
"Utopia\\Queue\\": "src/Queue" "Utopia\\Queue\\": "src/Queue"
} }
}, },
"autoload-dev": { "notification-url": "https://packagist.org/downloads/",
"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": [ "license": [
"MIT" "MIT"
], ],
@ -2687,14 +2677,18 @@
], ],
"description": "A powerful task queue.", "description": "A powerful task queue.",
"keywords": [ "keywords": [
"Tasks",
"framework", "framework",
"php", "php",
"queue", "queue",
"tasks",
"upf", "upf",
"utopia" "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", "name": "utopia-php/registry",
@ -3144,16 +3138,16 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "appwrite/sdk-generator", "name": "appwrite/sdk-generator",
"version": "0.36.0", "version": "0.36.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/appwrite/sdk-generator.git", "url": "https://github.com/appwrite/sdk-generator.git",
"reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a" "reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3a10f1f895ed71120442ff71eb6adec3fd6b4e8a", "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992",
"reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a", "reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3189,9 +3183,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": { "support": {
"issues": "https://github.com/appwrite/sdk-generator/issues", "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", "name": "doctrine/deprecations",
@ -3495,25 +3489,27 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.18.0", "version": "v5.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc",
"reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"php": ">=7.0" "php": ">=7.4"
}, },
"require-dev": { "require-dev": {
"ircmaxell/php-yacc": "^0.0.7", "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": [
"bin/php-parse" "bin/php-parse"
@ -3521,7 +3517,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.9-dev" "dev-master": "5.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -3545,9 +3541,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "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", "name": "phar-io/manifest",
@ -3772,16 +3768,16 @@
}, },
{ {
"name": "phpdocumentor/type-resolver", "name": "phpdocumentor/type-resolver",
"version": "1.7.3", "version": "1.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git", "url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc",
"reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3824,9 +3820,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": { "support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues", "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", "name": "phpspec/prophecy",
@ -3899,16 +3895,16 @@
}, },
{ {
"name": "phpstan/phpdoc-parser", "name": "phpstan/phpdoc-parser",
"version": "1.24.5", "version": "1.25.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git", "url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240",
"reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3940,9 +3936,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types", "description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": { "support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues", "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", "name": "phpunit/php-code-coverage",
@ -5382,16 +5378,16 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.8.0", "version": "3.8.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
"reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" "reference": "14f5fff1e64118595db5408e946f3a22c75807f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7",
"reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", "reference": "14f5fff1e64118595db5408e946f3a22c75807f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5401,11 +5397,11 @@
"php": ">=5.4.0" "php": ">=5.4.0"
}, },
"require-dev": { "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": [
"bin/phpcs", "bin/phpcbf",
"bin/phpcbf" "bin/phpcs"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
@ -5458,7 +5454,7 @@
"type": "open_collective" "type": "open_collective"
} }
], ],
"time": "2023-12-08T12:32:31+00:00" "time": "2024-01-11T20:47:48+00:00"
}, },
{ {
"name": "swoole/ide-helper", "name": "swoole/ide-helper",
@ -5831,9 +5827,7 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": [],
"utopia-php/queue": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View file

@ -12,24 +12,33 @@ class Retry extends Action
{ {
public static function getName(): string public static function getName(): string
{ {
return 'retry'; return 'retry-jobs';
} }
public function __construct() public function __construct()
{ {
$this $this
->desc('Retry Queue') ->desc('Retry failed jobs from a specific queue identified by the name parameter')
->param('name', '', new Text(128), 'Queue name') ->param('name', '', new Text(128), 'Queue name')
->inject('queue') ->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.'); Console::error('No failed jobs found.');
return; return;
} }