1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bernard\Queue; |
4
|
|
|
|
5
|
|
|
use Bernard\BernardEvents; |
6
|
|
|
use Bernard\Envelope; |
7
|
|
|
use Bernard\Event\EnvelopeEvent; |
8
|
|
|
use Bernard\Event\PingEvent; |
9
|
|
|
use Bernard\Event\RejectEnvelopeEvent; |
10
|
|
|
use Bernard\Router; |
11
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
12
|
|
|
|
13
|
|
|
class SyncQueue extends AbstractQueue |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var EventDispatcherInterface |
17
|
|
|
*/ |
18
|
|
|
protected $dispatcher; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Router |
22
|
|
|
*/ |
23
|
|
|
protected $router; |
24
|
|
|
|
25
|
|
|
public function __construct($name, EventDispatcherInterface $dispatcher, Router $router) |
26
|
|
|
{ |
27
|
|
|
parent::__construct($name); |
28
|
|
|
$this->dispatcher = $dispatcher; |
29
|
|
|
$this->router = $router; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Copy-pasted from Consumer::invoke() and modified |
34
|
|
|
* @param Envelope $envelope |
35
|
|
|
* @throws \Exception |
36
|
|
|
* @throws \Throwable |
37
|
|
|
*/ |
38
|
|
|
public function enqueue(Envelope $envelope) |
39
|
|
|
{ |
40
|
|
|
$this->errorIfClosed(); |
41
|
|
|
|
42
|
|
|
$queue = $this; |
43
|
|
|
try { |
44
|
|
|
$this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue)); |
45
|
|
|
$this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue)); |
46
|
|
|
|
47
|
|
|
// for 5.3 support where a function name is not a callable |
48
|
|
|
call_user_func($this->router->map($envelope), $envelope->getMessage()); |
49
|
|
|
|
50
|
|
|
// We successfully processed the message. |
51
|
|
|
$queue->acknowledge($envelope); |
52
|
|
|
|
53
|
|
|
$this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue)); |
54
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
55
|
|
|
$this->dispatcher->dispatch(BernardEvents::REJECT, new RejectEnvelopeEvent($envelope, $queue, $e)); |
56
|
|
|
throw $e; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function dequeue() |
64
|
|
|
{ |
65
|
|
|
$this->errorIfClosed(); |
66
|
|
|
|
67
|
|
|
// Sync queue is always empty |
68
|
|
|
return; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function peek($index = 0, $limit = 20) |
75
|
|
|
{ |
76
|
|
|
$this->errorIfClosed(); |
77
|
|
|
|
78
|
|
|
// Sync queue is always empty |
79
|
|
|
return []; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritdoc} |
84
|
|
|
*/ |
85
|
|
|
public function count() |
86
|
|
|
{ |
87
|
|
|
$this->errorIfClosed(); |
88
|
|
|
|
89
|
|
|
// Sync queue is always empty |
90
|
|
|
return 0; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.