-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rearranging namespaces to prep for factories
- Loading branch information
1 parent
fe3393e
commit 1d6d72c
Showing
16 changed files
with
251 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\EventListener; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Presque\Events; | ||
use Presque\Event\JobEvent; | ||
|
||
class JobRetryListener implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return array( | ||
Events::JOB_FINISHED => 'onJobFinished' | ||
); | ||
} | ||
|
||
public function onJobFinished(JobEvent $event) | ||
{ | ||
$job = $event->getJob(); | ||
|
||
if ($job->isError()) { | ||
$event->getQueue()->enqueue($job); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\Queue; | ||
|
||
use Presque\Storage\StorageInterface; | ||
use Presque\Job\JobInterface; | ||
use Presque\Job\Job; | ||
|
||
abstract class AbstractQueue implements QueueInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\Worker; | ||
|
||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Presque\Event\JobEvent; | ||
use Presque\Event\WorkerEvent; | ||
use Presque\Log\LoggerAwareInterface; | ||
use Presque\Log\LoggerInterface; | ||
use Presque\Queue\QueueInterface; | ||
use Presque\Job\JobInterface; | ||
use Presque\StatusInterface; | ||
use Presque\Events; | ||
|
||
abstract class AbstractWorker implements WorkerInterface, LoggerAwareInterface | ||
{ | ||
protected $id; | ||
protected $status; | ||
protected $queues; | ||
protected $eventDispatcher; | ||
protected $logger; | ||
|
||
public function __construct($id = null) | ||
{ | ||
if (null === $id) { | ||
$id = gethostname() . ':' . getmypid(); | ||
} | ||
|
||
$this->id = $id; | ||
$this->queues = new \SplObjectStorage(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setStatus($status) | ||
{ | ||
$this->status = $status; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function addQueue(QueueInterface $queue) | ||
{ | ||
$this->queues->attach($queue); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function removeQueue(QueueInterface $queue) | ||
{ | ||
if ($this->queues->contains($queue)) { | ||
$this->queues->detach($queue); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getQueues() | ||
{ | ||
return $this->queues; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null) | ||
{ | ||
$this->eventDispatcher = $eventDispatcher; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function hasEventDispatcher() | ||
{ | ||
return null !== $this->eventDispatcher; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setLogger(LoggerInterface $logger = null) | ||
{ | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function hasLogger() | ||
{ | ||
return null !== $this->logger; | ||
} | ||
} |
Oops, something went wrong.