mirror of
https://github.com/idanoo/laravel-resque.git
synced 2025-07-17 09:31:48 +00:00
Refactor
This commit is contained in:
parent
175123695d
commit
9e7b3a658e
9 changed files with 215 additions and 203 deletions
52
src/Worker.php
Normal file
52
src/Worker.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
namespace Hlgrrnhrdt\Resque;
|
||||
|
||||
/**
|
||||
* Worker
|
||||
*
|
||||
* @author Holger Reinhardt <holger.reinhardt@aboutyou.de>
|
||||
*/
|
||||
class Worker
|
||||
{
|
||||
/**
|
||||
* @var \Resque_Worker
|
||||
*/
|
||||
private $worker;
|
||||
|
||||
/**
|
||||
* @param \Resque_Worker $worker
|
||||
*/
|
||||
public function __construct(\Resque_Worker $worker)
|
||||
{
|
||||
$this->worker = $worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
return (string)$this->worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function stop()
|
||||
{
|
||||
list(, $pid,) = \explode(':', $this->id());
|
||||
return \posix_kill($pid, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Queue[]
|
||||
*/
|
||||
public function queues()
|
||||
{
|
||||
$queues = \array_map(function ($queue) {
|
||||
return new Queue($queue);
|
||||
}, $this->worker->queues());
|
||||
|
||||
return $queues;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue