Skip to content

Commit

Permalink
maintenance 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritdead committed Feb 28, 2017
1 parent cadc79b commit 6255387
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Exceptions/ResqueJobPerformException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use spiritdead\resque\exceptions\base\ResqueException;

/**
* Class ResqueJobPerformException
* @package spiritdead\resque\exceptions
*/
class ResqueJobPerformException extends ResqueException
{

Expand Down
13 changes: 13 additions & 0 deletions components/workers/ResqueWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 0 additions & 2 deletions components/workers/base/ResqueWorkerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ public function queues($fetch = true)
protected function startup()
{
$this->registerSigHandlers();
$this->pruneDeadWorkers();
$this->resqueInstance->events->trigger('beforeFirstFork', $this);
$this->registerWorker();
}

/**
Expand Down
6 changes: 6 additions & 0 deletions components/workers/base/ResqueWorkerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -31,4 +34,7 @@ public function doneWorking();
public function getWorking();

public function pruneDeadWorkers();

public function startup();

}
4 changes: 4 additions & 0 deletions controllers/ResqueJobFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use spiritdead\resque\components\jobs\ResqueJobInterface;
use spiritdead\resque\exceptions\base\ResqueException;

/**
* Class ResqueJobFactory
* @package spiritdead\resque\controllers
*/
class ResqueJobFactory
{
/**
Expand Down
7 changes: 7 additions & 0 deletions controllers/ResqueRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion controllers/base/ResqueJobFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
namespace spiritdead\resque\controllers\base;

use spiritdead\resque\jobs\base\ResqueJobInterface;
use spiritdead\resque\components\jobs\ResqueJobInterface;

/**
* Interface ResqueJobFactoryInterface
* @package spiritdead\resque\controllers\base
*/
interface ResqueJobFactoryInterface
{
/**
Expand Down
11 changes: 11 additions & 0 deletions helpers/ResqueLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@
*/
class ResqueLog extends AbstractLogger
{
/**
* @var bool
*/
public $verbose;

/**
* @var bool
*/
public $debug;

/**
* ResqueLog constructor.
* @param bool $verbose
* @param bool $debug
*/
public function __construct($verbose = false, $debug = false)
{
$this->verbose = $verbose;
Expand Down
9 changes: 8 additions & 1 deletion models/ResqueBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace spiritdead\resque\models;

/**
* Class ResqueBackend
* @package spiritdead\resque\models
*/
class ResqueBackend
{
/**
Expand Down Expand Up @@ -37,7 +41,7 @@ class ResqueBackend
/**
* ResqueBackend constructor.
* @param string $server
* @param int $port
* @param string $port
* @param int $database
*/
public function __construct(
Expand All @@ -50,6 +54,9 @@ public function __construct(
$this->database = $database;
}

/**
* @return string
*/
public function __toString()
{
return sprintf('%s:%s', $this->server, $this->port);
Expand Down
6 changes: 3 additions & 3 deletions plugins/schedule/ResqueScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -261,7 +262,6 @@ private function validateJob($class, $queue)
throw new ResqueException('Jobs must be put in a queue.');
}
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace spiritdead\resque\components\workers;
namespace spiritdead\resque\plugins\schedule\workers;

use Psr\Log\LogLevel;
use spiritdead\resque\components\jobs\base\ResqueJobBase;
Expand Down Expand Up @@ -170,12 +170,11 @@ public function enqueueDelayedItemsForTimestamp($timestamp)
/**
* Perform necessary actions to start a worker.
*/
protected function startup()
public function startup()
{
$this->registerSigHandlers();
$this->pruneDeadWorkers();
$this->resqueInstance->events->trigger('beforeFirstFork', $this);
$this->registerWorker();
parent::startup();
}

/**
Expand Down

0 comments on commit 6255387

Please sign in to comment.