mirror of
https://github.com/idanoo/laravel-resque.git
synced 2024-11-23 08:55:21 +00:00
2.0.0: Add namespacing (#1)
2.0.0: Namespace for idanoo/php-resque Co-Authored-By: idanoo <daniel@m2.nz> Co-Committed-By: idanoo <daniel@m2.nz>
This commit is contained in:
parent
591012d123
commit
926f8a887c
@ -1,22 +1,30 @@
|
|||||||
{
|
{
|
||||||
"name": "hlgrrnhrdt/laravel-resque",
|
"name": "idanoo/laravel-resque",
|
||||||
"authors": [
|
"type": "library",
|
||||||
{
|
"replace": {
|
||||||
"name": "Holger Reinhardt",
|
"hlgrrnhrdt/laravel-resque": "*"
|
||||||
"email": "hlgrrnhrdt@gmail.com"
|
},
|
||||||
}
|
"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": {
|
"require": {
|
||||||
"illuminate/console": "^5.2",
|
"illuminate/console": "^5.2",
|
||||||
"illuminate/config": "^5.2",
|
"illuminate/config": "^5.2",
|
||||||
"danhunsaker/php-resque": "^1.3"
|
"idanoo/php-resque": "^2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.4"
|
"phpunit/phpunit": "^9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Hlgrrnhrdt\\Resque\\": "src/"
|
"Idanoo\\Resque\\": "src/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Default Redis Config
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'default' => env('RESQUE_REDIS', 'resque'),
|
'default' => env('RESQUE_REDIS', 'resque'),
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Prefix
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'prefix' => env('RESQUE_PREFIX'),
|
'prefix' => env('RESQUE_PREFIX'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque\Console;
|
namespace Idanoo\Resque\Console;
|
||||||
|
|
||||||
use Hlgrrnhrdt\Resque\Resque;
|
use Idanoo\Resque\Resque;
|
||||||
use Illuminate\Console\Command as IlluminateCommand;
|
use Illuminate\Console\Command as IlluminateCommand;
|
||||||
use Resque_Worker;
|
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,12 +27,12 @@ class WorkCommand extends IlluminateCommand
|
|||||||
protected $description = 'Run a resque worker';
|
protected $description = 'Run a resque worker';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Hlgrrnhrdt\Resque\Resque
|
* @var \Idanoo\Resque\Resque
|
||||||
*/
|
*/
|
||||||
private $resque;
|
private $resque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Hlgrrnhrdt\Resque\Resque $resque
|
* @param \Idanoo\Resque\Resque $resque
|
||||||
*/
|
*/
|
||||||
public function __construct(Resque $resque)
|
public function __construct(Resque $resque)
|
||||||
{
|
{
|
||||||
@ -64,7 +63,7 @@ class WorkCommand extends IlluminateCommand
|
|||||||
*/
|
*/
|
||||||
private function startWorker(array $queues, $interval = 5)
|
private function startWorker(array $queues, $interval = 5)
|
||||||
{
|
{
|
||||||
$worker = new Resque_Worker($queues);
|
$worker = new \Resque\Worker($queues);
|
||||||
$this->info(\sprintf('Starting worker %s', $worker));
|
$this->info(\sprintf('Starting worker %s', $worker));
|
||||||
$worker->work($interval);
|
$worker->work($interval);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque;
|
|
||||||
|
namespace Idanoo\Resque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job
|
* Job
|
||||||
@ -44,7 +45,7 @@ abstract class Job
|
|||||||
*/
|
*/
|
||||||
public function name()
|
public function name()
|
||||||
{
|
{
|
||||||
return \get_class($this);
|
return get_class($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque;
|
|
||||||
|
namespace Idanoo\Resque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue
|
* Queue
|
||||||
@ -34,7 +35,7 @@ class Queue
|
|||||||
*/
|
*/
|
||||||
public function size()
|
public function size()
|
||||||
{
|
{
|
||||||
return \Resque::size($this->name);
|
return \Resque\Resque::size($this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,10 +43,10 @@ class Queue
|
|||||||
*/
|
*/
|
||||||
public function jobs()
|
public function jobs()
|
||||||
{
|
{
|
||||||
$result = \Resque::redis()->lrange('queue:' . $this->name, 0, -1);
|
$result = \Resque\Resque::redis()->lrange('queue:' . $this->name, 0, -1);
|
||||||
$jobs = [];
|
$jobs = [];
|
||||||
foreach ($result as $job) {
|
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;
|
return $jobs;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque;
|
|
||||||
|
namespace Idanoo\Resque;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class Resque
|
|||||||
*/
|
*/
|
||||||
public function setPrefix($prefix)
|
public function setPrefix($prefix)
|
||||||
{
|
{
|
||||||
\Resque_Redis::prefix($prefix);
|
\Resque\Redis::prefix($prefix);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ class Resque
|
|||||||
* @param Job $job
|
* @param Job $job
|
||||||
* @param bool $trackStatus
|
* @param bool $trackStatus
|
||||||
*
|
*
|
||||||
* @return null|\Resque_Job_Status
|
* @return null|\Resque\Job\Status
|
||||||
*/
|
*/
|
||||||
public function enqueueOnce(Job $job, $trackStatus = false)
|
public function enqueueOnce(Job $job, $trackStatus = false)
|
||||||
{
|
{
|
||||||
@ -43,13 +44,13 @@ class Resque
|
|||||||
|
|
||||||
foreach ($queue->jobs() as $queuedJob) {
|
foreach ($queue->jobs() as $queuedJob) {
|
||||||
if (true === $job->equals($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) {
|
foreach ($this->working() as $workingJob) {
|
||||||
if (true === $job->equals($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()
|
private function working()
|
||||||
{
|
{
|
||||||
$jobs = [];
|
$jobs = [];
|
||||||
foreach (\Resque::redis()->smembers('workers') as $worker) {
|
foreach (\Resque\Resque::redis()->smembers('workers') as $worker) {
|
||||||
$job = \Resque::redis()->get('worker:' . $worker);
|
$job = \Resque\Resque::redis()->get('worker:' . $worker);
|
||||||
$job = \json_decode($job, true);
|
$job = \json_decode($job, true);
|
||||||
if (!\json_last_error()) {
|
if (!\json_last_error()) {
|
||||||
$jobs[] = (new \Resque_Job($job['queue'], $job['payload']))
|
$jobs[] = (new \Resque\Job\Job($job['queue'], $job['payload']))
|
||||||
->getInstance();
|
->getInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,21 +83,21 @@ class Resque
|
|||||||
*/
|
*/
|
||||||
public function enqueue(Job $job, $trackStatus = false)
|
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) {
|
if (true === $trackStatus) {
|
||||||
return new \Resque_Job_Status($id);
|
return new \Resque\Job\Status($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Resque_Redis
|
* @return \Resque\Redis
|
||||||
*/
|
*/
|
||||||
public function redis()
|
public function redis()
|
||||||
{
|
{
|
||||||
return \Resque::redis();
|
return \Resque\Resque::redis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,6 +107,6 @@ class Resque
|
|||||||
*/
|
*/
|
||||||
public function fork()
|
public function fork()
|
||||||
{
|
{
|
||||||
return \Resque::fork();
|
return \Resque\Resque::fork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque;
|
|
||||||
|
|
||||||
use Hlgrrnhrdt\Resque\Console\WorkCommand;
|
namespace Idanoo\Resque;
|
||||||
|
|
||||||
|
use Idanoo\Resque\Console\WorkCommand;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,6 +67,6 @@ class ResqueServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
$dsn = sprintf('redis://%s/%s', $server, $database);
|
$dsn = sprintf('redis://%s/%s', $server, $database);
|
||||||
|
|
||||||
\Resque::setBackend($dsn);
|
\Resque\Resque::setBackend($dsn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Hlgrrnhrdt\Resque;
|
namespace Idanoo\Resque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Worker
|
* Worker
|
||||||
@ -9,14 +9,14 @@ namespace Hlgrrnhrdt\Resque;
|
|||||||
class Worker
|
class Worker
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Resque_Worker
|
* @var \Resque\Worker
|
||||||
*/
|
*/
|
||||||
private $worker;
|
private $worker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Resque_Worker $worker
|
* @param \Resque\Worker $worker
|
||||||
*/
|
*/
|
||||||
public function __construct(\Resque_Worker $worker)
|
public function __construct(\Resque\Worker $worker)
|
||||||
{
|
{
|
||||||
$this->worker = $worker;
|
$this->worker = $worker;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user