1 | <?php |
||
13 | class PheanstalkDriver extends AbstractDriver |
||
14 | { |
||
15 | protected $pheanstalk; |
||
16 | |||
17 | /** |
||
18 | * @param PheanstalkInterface $pheanstalk |
||
19 | */ |
||
20 | public function __construct(PheanstalkInterface $pheanstalk) |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public function listQueues() |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | public function createQueue($queueName, array $options = []) |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function countMessages($queueName) |
||
44 | { |
||
45 | $stats = $this->pheanstalk->statsTube($queueName); |
||
46 | |||
47 | return $stats['current-jobs-ready']; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function pushMessage($queueName, $message, array $options = []) |
||
54 | { |
||
55 | $options = $this->validatePushOptions($options); |
||
56 | |||
57 | $this->pheanstalk->putInTube( |
||
58 | $queueName, |
||
59 | $message, |
||
60 | $options['priority'], |
||
61 | $options['delay'], |
||
62 | $options['ttr'] |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function popMessage($queueName, $duration = 5) |
||
70 | { |
||
71 | if ($job = $this->pheanstalk->reserveFromTube($queueName, $duration)) { |
||
72 | return [$job->getData(), $job]; |
||
73 | } |
||
74 | |||
75 | return array(null, null); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function acknowledgeMessage($queueName, $receipt) |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function peekQueue($queueName, $index = 0, $limit = 20) |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function removeQueue($queueName) |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function info() |
||
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | public function configurePushOptions(OptionsResolver $resolver) |
||
123 | } |
||
124 |