mirror of
https://github.com/idanoo/laravel-resque.git
synced 2024-11-22 00:21:58 +00:00
fix detect duplicate job
This commit is contained in:
parent
e230e66b48
commit
0663765b47
@ -10,8 +10,7 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'connection' => [
|
'connection' => [
|
||||||
'host' => env('RESQUE_REDIS_HOST', 'localhost'),
|
'server' => env('RESQUE_REDIS_SERVER', 'localhost:6379'),
|
||||||
'port' => env('RESQUE_REDIS_PORT', 6379),
|
|
||||||
'db' => env('RESQUE_REDIS_DB', 0),
|
'db' => env('RESQUE_REDIS_DB', 0),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -76,8 +76,11 @@ class WorkCommand extends IlluminateCommand
|
|||||||
*/
|
*/
|
||||||
private function startWorker(array $queues, $interval = 5, $logLevel = Resque_Worker::LOG_NONE)
|
private function startWorker(array $queues, $interval = 5, $logLevel = Resque_Worker::LOG_NONE)
|
||||||
{
|
{
|
||||||
$worker = $this->manager->startWorker($queues, $interval, $logLevel);
|
$worker = new Resque_Worker($queues);
|
||||||
|
$worker->logLevel = $logLevel;
|
||||||
|
|
||||||
$this->info(sprintf('Starting worker %s', $worker));
|
$this->info(sprintf('Starting worker %s', $worker));
|
||||||
|
$worker->work($interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,10 +62,8 @@ class ResqueManager
|
|||||||
$queue = new Queue($job->queue());
|
$queue = new Queue($job->queue());
|
||||||
|
|
||||||
foreach ($queue->jobs() as $queuedJob) {
|
foreach ($queue->jobs() as $queuedJob) {
|
||||||
if ($job->payload['class'] === get_class($queuedJob) && count(array_intersect($queuedJob->getArguments(),
|
if (true === $this->isDuplicateJob($job, $queuedJob)) {
|
||||||
$job->arguments())) === $job->arguments()
|
return ($trackStatus) ? new \Resque_Job_Status($queuedJob->payload['id']) : null;
|
||||||
) {
|
|
||||||
return ($trackStatus) ? new \Resque_Job_Status($job->payload['id']) : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,18 +98,14 @@ class ResqueManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $queues
|
* @param \Hlgrrnhrdt\Resque\Job $job
|
||||||
* @param int $interval
|
* @param $queuedJob
|
||||||
* @param int $logLevel
|
|
||||||
*
|
*
|
||||||
* @return \Resque_Worker
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function startWorker(array $queues, $interval = 5, $logLevel = Resque_Worker::LOG_NONE)
|
private function isDuplicateJob(Job $job, \Resque_Job $queuedJob)
|
||||||
{
|
{
|
||||||
$worker = new Resque_Worker($queues);
|
return $queuedJob->payload['class'] === get_class($queuedJob)
|
||||||
$worker->logLevel = $logLevel;
|
&& count(array_intersect($queuedJob->getArguments(), $job->arguments())) === count($job->arguments());
|
||||||
$worker->work($interval);
|
|
||||||
|
|
||||||
return $worker;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class ResqueServiceProvider extends ServiceProvider
|
|||||||
$config = $this->app['config']['resque.connection'];
|
$config = $this->app['config']['resque.connection'];
|
||||||
|
|
||||||
$resque = new Resque();
|
$resque = new Resque();
|
||||||
$resque->setBackend(implode(':', [$config['host'], $config['port']]), $config['db']);
|
$resque->setBackend($config['server'], $config['db']);
|
||||||
|
|
||||||
return new ResqueManager($resque, $this->app['config']['resque.trackStatus']);
|
return new ResqueManager($resque, $this->app['config']['resque.trackStatus']);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user