|
1
|
|
|
<?php namespace Comodojo\Extender\Queue; |
|
2
|
|
|
|
|
3
|
|
|
use \Comodojo\Daemon\Process; |
|
4
|
|
|
use \Comodojo\Extender\Task\Request; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @package Comodojo Extender |
|
8
|
|
|
* @author Marco Giovinazzi <[email protected]> |
|
9
|
|
|
* @license MIT |
|
10
|
|
|
* |
|
11
|
|
|
* LICENSE: |
|
12
|
|
|
* |
|
13
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
14
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
15
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
16
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
17
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
18
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
19
|
|
|
* THE SOFTWARE. |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
class SocketCommands { |
|
23
|
|
|
|
|
24
|
|
|
public function queueAdd(Process $daemon, Request $request = null) { |
|
25
|
|
|
|
|
26
|
|
|
return self::getManager($daemon)->add($request); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function queueAddBulk(Process $daemon, array $requests = []) { |
|
31
|
|
|
|
|
32
|
|
|
return self::getManager($daemon)->addBulk($requests); |
|
33
|
|
|
|
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
View Code Duplication |
public function queueInfo(Process $daemon, $data = null) { |
|
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
$configuration = $daemon->getConfiguration(); |
|
|
|
|
|
|
39
|
|
|
$base_path = $configuration->get('base-path'); |
|
40
|
|
|
$lock_path = $configuration->get('run-path'); |
|
41
|
|
|
$lock_file = "$base_path/$lock_path/queue.worker.lock"; |
|
42
|
|
|
|
|
43
|
|
|
return unserialize(file_get_contents($lock_file)); |
|
44
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
protected static function getManager(Process $daemon) { |
|
48
|
|
|
|
|
49
|
|
|
return new Manager( |
|
50
|
|
|
$daemon->getConfiguration(), |
|
|
|
|
|
|
51
|
|
|
$daemon->getLogger(), |
|
52
|
|
|
$daemon->getEvents() |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):