Skip to content

Commit aeabb5b

Browse files
committed
Constructor on top with default logger
1 parent cdc5c3f commit aeabb5b

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

lib/Resque/Worker.php

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,34 @@ class Resque_Worker
4949
*/
5050
private $child = null;
5151

52-
public function __construct()
52+
/**
53+
* Instantiate a new worker, given a list of queues that it should be working
54+
* on. The list of queues should be supplied in the priority that they should
55+
* be checked for jobs (first come, first served)
56+
*
57+
* Passing a single '*' allows the worker to work on all queues in alphabetical
58+
* order. You can easily add new queues dynamically and have them worked on using
59+
* this method.
60+
*
61+
* @param string|array $queues String with a single queue name, array with multiple.
62+
*/
63+
public function __construct($queues)
5364
{
5465
$this->logger = new Resque_Log();
66+
67+
if(!is_array($queues)) {
68+
$queues = array($queues);
69+
}
70+
71+
$this->queues = $queues;
72+
if(function_exists('gethostname')) {
73+
$hostname = gethostname();
74+
}
75+
else {
76+
$hostname = php_uname('n');
77+
}
78+
$this->hostname = $hostname;
79+
$this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues);
5580
}
5681

5782
/**
@@ -112,34 +137,6 @@ public function setId($workerId)
112137
$this->id = $workerId;
113138
}
114139

115-
/**
116-
* Instantiate a new worker, given a list of queues that it should be working
117-
* on. The list of queues should be supplied in the priority that they should
118-
* be checked for jobs (first come, first served)
119-
*
120-
* Passing a single '*' allows the worker to work on all queues in alphabetical
121-
* order. You can easily add new queues dynamically and have them worked on using
122-
* this method.
123-
*
124-
* @param string|array $queues String with a single queue name, array with multiple.
125-
*/
126-
public function __construct($queues)
127-
{
128-
if(!is_array($queues)) {
129-
$queues = array($queues);
130-
}
131-
132-
$this->queues = $queues;
133-
if(function_exists('gethostname')) {
134-
$hostname = gethostname();
135-
}
136-
else {
137-
$hostname = php_uname('n');
138-
}
139-
$this->hostname = $hostname;
140-
$this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues);
141-
}
142-
143140
/**
144141
* The primary loop for a worker which when called on an instance starts
145142
* the worker's life cycle.

0 commit comments

Comments
 (0)