diff --git a/Exceptions/ResqueJobPerformException.php b/Exceptions/ResqueJobPerformException.php index e765bb5..d03f07c 100644 --- a/Exceptions/ResqueJobPerformException.php +++ b/Exceptions/ResqueJobPerformException.php @@ -4,6 +4,10 @@ use spiritdead\resque\exceptions\base\ResqueException; +/** + * Class ResqueJobPerformException + * @package spiritdead\resque\exceptions + */ class ResqueJobPerformException extends ResqueException { diff --git a/components/workers/ResqueWorker.php b/components/workers/ResqueWorker.php index fe8b30d..a9f6247 100644 --- a/components/workers/ResqueWorker.php +++ b/components/workers/ResqueWorker.php @@ -11,6 +11,10 @@ use spiritdead\resque\exceptions\base\ResqueException; use spiritdead\resque\exceptions\ResqueJobForceExitException; +/** + * Class ResqueWorker + * @package spiritdead\resque\components\workers + */ class ResqueWorker extends ResqueWorkerBase implements ResqueWorkerInterface { /** @@ -132,6 +136,15 @@ public function perform(ResqueJobBase $job) $this->logger->log(LogLevel::NOTICE, '{job} has finished', ['job' => $job]); } + /** + * Perform necessary actions to start a worker. + */ + public function startup() + { + $this->pruneDeadWorkers(); + $this->registerWorker(); + } + /** * Given a worker ID, find it and return an instantiated worker class for it. * diff --git a/components/workers/base/ResqueWorkerBase.php b/components/workers/base/ResqueWorkerBase.php index 9f30dab..1b91dcb 100644 --- a/components/workers/base/ResqueWorkerBase.php +++ b/components/workers/base/ResqueWorkerBase.php @@ -155,9 +155,7 @@ public function queues($fetch = true) protected function startup() { $this->registerSigHandlers(); - $this->pruneDeadWorkers(); $this->resqueInstance->events->trigger('beforeFirstFork', $this); - $this->registerWorker(); } /** diff --git a/components/workers/base/ResqueWorkerInterface.php b/components/workers/base/ResqueWorkerInterface.php index 065f0eb..c140578 100644 --- a/components/workers/base/ResqueWorkerInterface.php +++ b/components/workers/base/ResqueWorkerInterface.php @@ -8,6 +8,9 @@ * Interface ResqueWorkerInterface * @package spiritdead\resque\components\workers\base */ +abstract class a { + +} interface ResqueWorkerInterface { public function work($interval = ResqueWorkerBase::DEFAULT_INTERVAL, $blocking = false); @@ -31,4 +34,7 @@ public function doneWorking(); public function getWorking(); public function pruneDeadWorkers(); + + public function startup(); + } \ No newline at end of file diff --git a/controllers/ResqueJobFactory.php b/controllers/ResqueJobFactory.php index f711a4c..7cce1cc 100644 --- a/controllers/ResqueJobFactory.php +++ b/controllers/ResqueJobFactory.php @@ -5,6 +5,10 @@ use spiritdead\resque\components\jobs\ResqueJobInterface; use spiritdead\resque\exceptions\base\ResqueException; +/** + * Class ResqueJobFactory + * @package spiritdead\resque\controllers + */ class ResqueJobFactory { /** diff --git a/controllers/ResqueRedis.php b/controllers/ResqueRedis.php index 0a094b0..b51dc0a 100644 --- a/controllers/ResqueRedis.php +++ b/controllers/ResqueRedis.php @@ -250,11 +250,18 @@ public function __call($name, $args) } } + /** + * @return string + */ public function getPrefix() { return $this->defaultNamespace; } + /** + * @param $string + * @return string + */ public function removePrefix($string) { $prefix = $this->defaultNamespace; diff --git a/controllers/base/ResqueJobFactoryInterface.php b/controllers/base/ResqueJobFactoryInterface.php index 1dabeb7..a5d8d51 100644 --- a/controllers/base/ResqueJobFactoryInterface.php +++ b/controllers/base/ResqueJobFactoryInterface.php @@ -1,8 +1,12 @@ verbose = $verbose; diff --git a/models/ResqueBackend.php b/models/ResqueBackend.php index 81e3ca9..3e58c35 100644 --- a/models/ResqueBackend.php +++ b/models/ResqueBackend.php @@ -2,6 +2,10 @@ namespace spiritdead\resque\models; +/** + * Class ResqueBackend + * @package spiritdead\resque\models + */ class ResqueBackend { /** @@ -37,7 +41,7 @@ class ResqueBackend /** * ResqueBackend constructor. * @param string $server - * @param int $port + * @param string $port * @param int $database */ public function __construct( @@ -50,6 +54,9 @@ public function __construct( $this->database = $database; } + /** + * @return string + */ public function __toString() { return sprintf('%s:%s', $this->server, $this->port); diff --git a/plugins/schedule/ResqueScheduler.php b/plugins/schedule/ResqueScheduler.php index 8eb1de2..bad5fbf 100644 --- a/plugins/schedule/ResqueScheduler.php +++ b/plugins/schedule/ResqueScheduler.php @@ -58,7 +58,7 @@ public function enqueueAt($at, $queue, $class, $args = []) /** * Directly append an item to the delayed queue schedule. * - * @param DateTime|int $timestamp Timestamp job is scheduled to be run at. + * @param \DateTime|int $timestamp Timestamp job is scheduled to be run at. * @param array $item Hash of item to be pushed to schedule. */ public function delayedPush($timestamp, $item) @@ -147,6 +147,7 @@ public function removeDelayedJobFromTimestamp($timestamp, $queue, $class, $args) * @param string $queue Name of the queue the job will be placed on. * @param string $class Name of the job class. * @param array $args Array of job arguments. + * @return array */ private function jobToHash($queue, $class, $args) { @@ -206,7 +207,7 @@ private function getTimestamp($timestamp) * that any jobs scheduled for the past when the worker wasn't running are * also queued up. * - * @param \DateTime|int $timestamp Instance of DateTime or UNIX timestamp. + * @param \DateTime|int $at Instance of DateTime or UNIX timestamp. * Defaults to now. * @return int|false UNIX timestamp, or false if nothing to run. */ @@ -261,7 +262,6 @@ private function validateJob($class, $queue) throw new ResqueException('Jobs must be put in a queue.'); } } - return true; } } diff --git a/components/workers/ResqueWorkerScheduler.php b/plugins/schedule/workers/ResqueWorkerScheduler.php similarity index 97% rename from components/workers/ResqueWorkerScheduler.php rename to plugins/schedule/workers/ResqueWorkerScheduler.php index daea08b..42f8d86 100644 --- a/components/workers/ResqueWorkerScheduler.php +++ b/plugins/schedule/workers/ResqueWorkerScheduler.php @@ -1,6 +1,6 @@ registerSigHandlers(); $this->pruneDeadWorkers(); - $this->resqueInstance->events->trigger('beforeFirstFork', $this); $this->registerWorker(); + parent::startup(); } /**