From 951d9d37b56da665e39a1ea9ea5af21540339bf7 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Wed, 29 Feb 2012 22:32:52 -0600 Subject: [PATCH 1/7] updated method comments --- lib/Resque.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Resque.php b/lib/Resque.php index d0be465..0efa24d 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -24,7 +24,8 @@ class Resque * the redis server that Resque will talk to. * * @param mixed $server Host/port combination separated by a colon, or - * a nested array of servers with host/port pairs. + * a nested array of servers with host/port pairs. + * @param int $database */ public static function setBackend($server, $database = 0) { @@ -88,6 +89,8 @@ class Resque /** * Return the size (number of pending jobs) of the specified queue. * + * @param $queue name of the queue to be checked for pendign jobs + * * @return int The size of the queue. */ public static function size($queue) @@ -101,7 +104,9 @@ class Resque * @param string $queue The name of the queue to place the job in. * @param string $class The name of the class that contains the code to execute the job. * @param array $args Any optional arguments that should be passed when the job is executed. - * @param boolean $monitor Set to true to be able to monitor the status of a job. + * @param boolean $trackStatus Set to true to be able to monitor the status of a job. + * + * @return string */ public static function enqueue($queue, $class, $args = null, $trackStatus = false) { From 8f06294048f7cc8ea7954230ea9426085ca6c0b4 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Thu, 1 Mar 2012 19:13:34 -0600 Subject: [PATCH 2/7] method comments updated --- lib/Resque/Failure.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Resque/Failure.php b/lib/Resque/Failure.php index 844e343..9f6d89a 100644 --- a/lib/Resque/Failure.php +++ b/lib/Resque/Failure.php @@ -19,10 +19,10 @@ class Resque_Failure /** * Create a new failed job on the backend. * - * @param object $payload The contents of the job that has just failed. - * @param object $exception The exception generated when the job failed to run. - * @param object $worker Instance of Resque_Worker that was running this job when it failed. - * @param string $queue The name of the queue that this job was fetched from. + * @param object $payload The contents of the job that has just failed. + * @param \Exception $exception The exception generated when the job failed to run. + * @param \Resque_Worker $worker Instance of Resque_Worker that was running this job when it failed. + * @param string $queue The name of the queue that this job was fetched from. */ public static function create($payload, Exception $exception, Resque_Worker $worker, $queue) { From ef859b6fc5861873daedfaf4959b08b125cf9dd0 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Thu, 1 Mar 2012 19:21:06 -0600 Subject: [PATCH 3/7] updated method comments --- lib/Resque/Job.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Resque/Job.php b/lib/Resque/Job.php index 654271a..e2002ad 100644 --- a/lib/Resque/Job.php +++ b/lib/Resque/Job.php @@ -52,6 +52,8 @@ class Resque_Job * @param string $class The name of the class that contains the code to execute the job. * @param array $args Any optional arguments that should be passed when the job is executed. * @param boolean $monitor Set to true to be able to monitor the status of a job. + * + * @return string */ public static function create($queue, $class, $args = null, $monitor = false) { @@ -154,7 +156,7 @@ class Resque_Job ); } - $this->instance = new $this->payload['class']; + $this->instance = new $this->payload['class'](); $this->instance->job = $this; $this->instance->args = $this->getArguments(); return $this->instance; @@ -164,6 +166,7 @@ class Resque_Job * Actually execute a job by calling the perform method on the class * associated with the job with the supplied arguments. * + * @return bool * @throws Resque_Exception When the job's class could not be found or it does not contain a perform method. */ public function perform() @@ -194,6 +197,8 @@ class Resque_Job /** * Mark the current job as having failed. + * + * @param $exception */ public function fail($exception) { @@ -216,6 +221,7 @@ class Resque_Job /** * Re-queue the current job. + * @return string */ public function recreate() { From 3b59fa5dbcf23b4643d1e9e8395e1e58038fbec6 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Thu, 1 Mar 2012 19:21:58 -0600 Subject: [PATCH 4/7] method comment changes --- lib/Resque/Worker.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index a180d27..189cf81 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -53,7 +53,7 @@ class Resque_Worker * @var Resque_Job Current job, if any, being processed by this worker. */ private $currentJob = null; - + /** * @var int Process ID of child worker processes. */ @@ -61,6 +61,7 @@ class Resque_Worker /** * Return all workers known to Resque as instantiated instances. + * @return array */ public static function all() { @@ -192,12 +193,12 @@ class Resque_Worker $this->child = $this->fork(); // Forked and we're the child. Run the job. - if($this->child === 0 || $this->child === false) { + if ($this->child === 0 || $this->child === false) { $status = 'Processing ' . $job->queue . ' since ' . strftime('%F %T'); $this->updateProcLine($status); $this->log($status, self::LOG_VERBOSE); $this->perform($job); - if($this->child === 0) { + if ($this->child === 0) { exit(0); } } @@ -228,11 +229,12 @@ class Resque_Worker /** * Process a single job. * - * @param object|null $job The job to be processed. + * @param Resque_Job $job The job to be processed. */ public function perform(Resque_Job $job) { try { + $this->log("afterFork being triggered", self::LOG_VERBOSE); Resque_Event::trigger('afterFork', $job); $job->perform(); } From cc871c06ab662dc38b33feca595f15edac03eab4 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Thu, 15 Mar 2012 20:03:34 -0500 Subject: [PATCH 5/7] fixed spelling error and removed debug code --- lib/Resque.php | 2 +- lib/Resque/Worker.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Resque.php b/lib/Resque.php index ded12a4..df211a6 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -128,7 +128,7 @@ class Resque /** * Return the size (number of pending jobs) of the specified queue. * - * @param $queue name of the queue to be checked for pendign jobs + * @param $queue name of the queue to be checked for pending jobs * * @return int The size of the queue. */ diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index fc2e9d9..31f2f3c 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -234,7 +234,6 @@ class Resque_Worker public function perform(Resque_Job $job) { try { - $this->log("afterFork being triggered", self::LOG_VERBOSE); Resque_Event::trigger('afterFork', $job); $job->perform(); } @@ -584,4 +583,4 @@ class Resque_Worker return Resque_Stat::get($stat . ':' . $this); } } -?> \ No newline at end of file +?> From 016f046a6a557cae0ceff9d66c00bab8b02941a5 Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Mon, 19 Mar 2012 07:14:02 +0800 Subject: [PATCH 6/7] Merge branch 'master', remote branch 'upstream/master' From 76c06a1349b2dc2a129936b2af3f863aa63aed7d Mon Sep 17 00:00:00 2001 From: Chaitanya Kuber Date: Thu, 22 Mar 2012 12:20:16 +0800 Subject: [PATCH 7/7] now setting the queue name onto the job instance --- lib/Resque/Job.php | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 lib/Resque/Job.php diff --git a/lib/Resque/Job.php b/lib/Resque/Job.php old mode 100644 new mode 100755 index e2002ad..0d275a1 --- a/lib/Resque/Job.php +++ b/lib/Resque/Job.php @@ -159,6 +159,7 @@ class Resque_Job $this->instance = new $this->payload['class'](); $this->instance->job = $this; $this->instance->args = $this->getArguments(); + $this->instance->queue = $this->queue; return $this->instance; }