From 926f8a887cc256d9433c8cee8c4d41f7ec3f2dcc Mon Sep 17 00:00:00 2001 From: idanoo Date: Fri, 19 Feb 2021 13:44:10 +1300 Subject: [PATCH] 2.0.0: Add namespacing (#1) 2.0.0: Namespace for idanoo/php-resque Co-Authored-By: idanoo Co-Committed-By: idanoo --- composer.json | 28 ++++++++++++++++++---------- config/resque.php | 17 ----------------- src/Console/WorkCommand.php | 11 +++++------ src/Job.php | 5 +++-- src/Queue.php | 9 +++++---- src/Resque.php | 27 ++++++++++++++------------- src/ResqueServiceProvider.php | 7 ++++--- src/Worker.php | 8 ++++---- 8 files changed, 53 insertions(+), 59 deletions(-) diff --git a/composer.json b/composer.json index 570bf22..dde9a65 100644 --- a/composer.json +++ b/composer.json @@ -1,22 +1,30 @@ { - "name": "hlgrrnhrdt/laravel-resque", - "authors": [ - { - "name": "Holger Reinhardt", - "email": "hlgrrnhrdt@gmail.com" - } - ], + "name": "idanoo/laravel-resque", + "type": "library", + "replace": { + "hlgrrnhrdt/laravel-resque": "*" + }, + "description": "Wrapper for idanoo/php-resque (Laravel/Lumen ^5.2.0)", + "keywords": ["job", "background", "redis", "resque", "php"], + "homepage": "https://www.gitlab.com/idanoo/laravel-resque/", + "license": "MIT", + "authors": [ + { + "name": "Daniel Mason", + "email": "daniel@m2.nz" + } + ], "require": { "illuminate/console": "^5.2", "illuminate/config": "^5.2", - "danhunsaker/php-resque": "^1.3" + "idanoo/php-resque": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { - "Hlgrrnhrdt\\Resque\\": "src/" + "Idanoo\\Resque\\": "src/" } } } diff --git a/config/resque.php b/config/resque.php index b53cb98..3a0c9bd 100644 --- a/config/resque.php +++ b/config/resque.php @@ -1,23 +1,6 @@ env('RESQUE_REDIS', 'resque'), - - /* - |-------------------------------------------------------------------------- - | Prefix - |-------------------------------------------------------------------------- - | - */ - 'prefix' => env('RESQUE_PREFIX'), - ]; diff --git a/src/Console/WorkCommand.php b/src/Console/WorkCommand.php index 9b01c38..492c2dd 100644 --- a/src/Console/WorkCommand.php +++ b/src/Console/WorkCommand.php @@ -1,9 +1,8 @@ info(\sprintf('Starting worker %s', $worker)); $worker->work($interval); } diff --git a/src/Job.php b/src/Job.php index 6a63bbc..cb0a269 100644 --- a/src/Job.php +++ b/src/Job.php @@ -1,5 +1,6 @@ name); + return \Resque\Resque::size($this->name); } /** @@ -42,10 +43,10 @@ class Queue */ public function jobs() { - $result = \Resque::redis()->lrange('queue:' . $this->name, 0, -1); + $result = \Resque\Resque::redis()->lrange('queue:' . $this->name, 0, -1); $jobs = []; foreach ($result as $job) { - $jobs[] = (new \Resque_Job($this->name, \json_decode($job, true)))->getInstance(); + $jobs[] = (new \Resque\Job\Job($this->name, \json_decode($job, true)))->getInstance(); } return $jobs; diff --git a/src/Resque.php b/src/Resque.php index 1da773a..87e2435 100644 --- a/src/Resque.php +++ b/src/Resque.php @@ -1,5 +1,6 @@ jobs() as $queuedJob) { if (true === $job->equals($queuedJob)) { - return ($trackStatus) ? new \Resque_Job_Status($queuedJob->job->payload['id']) : null; + return ($trackStatus) ? new \Resque\Job\Status($queuedJob->job->payload['id']) : null; } } foreach ($this->working() as $workingJob) { if (true === $job->equals($workingJob)) { - return ($trackStatus) ? new \Resque_Job_Status($workingJob->job->payload['id']) : null; + return ($trackStatus) ? new \Resque\Job\Status($workingJob->job->payload['id']) : null; } } @@ -62,11 +63,11 @@ class Resque private function working() { $jobs = []; - foreach (\Resque::redis()->smembers('workers') as $worker) { - $job = \Resque::redis()->get('worker:' . $worker); + foreach (\Resque\Resque::redis()->smembers('workers') as $worker) { + $job = \Resque\Resque::redis()->get('worker:' . $worker); $job = \json_decode($job, true); if (!\json_last_error()) { - $jobs[] = (new \Resque_Job($job['queue'], $job['payload'])) + $jobs[] = (new \Resque\Job\Job($job['queue'], $job['payload'])) ->getInstance(); } } @@ -82,21 +83,21 @@ class Resque */ public function enqueue(Job $job, $trackStatus = false) { - $id = \Resque::enqueue($job->queue(), $job->name(), $job->arguments(), $trackStatus); + $id = \Resque\Resque::enqueue($job->queue(), $job->name(), $job->arguments(), $trackStatus); if (true === $trackStatus) { - return new \Resque_Job_Status($id); + return new \Resque\Job\Status($id); } return null; } /** - * @return \Resque_Redis + * @return \Resque\Redis */ public function redis() { - return \Resque::redis(); + return \Resque\Resque::redis(); } /** @@ -106,6 +107,6 @@ class Resque */ public function fork() { - return \Resque::fork(); + return \Resque\Resque::fork(); } } diff --git a/src/ResqueServiceProvider.php b/src/ResqueServiceProvider.php index 87d0510..279e4e4 100644 --- a/src/ResqueServiceProvider.php +++ b/src/ResqueServiceProvider.php @@ -1,7 +1,8 @@ worker = $worker; }