1 | <?php |
||
16 | class Controller |
||
17 | { |
||
18 | use RedisTrait; |
||
19 | |||
20 | /** |
||
21 | * @var MessageQueueGateway |
||
22 | */ |
||
23 | private $messageQueue; |
||
24 | |||
25 | /** |
||
26 | * @var Stats |
||
27 | */ |
||
28 | private $stats; |
||
29 | |||
30 | /** |
||
31 | * @Inject({"@Stats.Stats", "@MessageQueue.Gateway"}) |
||
32 | * @param Stats $stats |
||
33 | * @param MessageQueueGateway $gateway |
||
34 | */ |
||
35 | 3 | public function __construct(Stats $stats, MessageQueueGateway $gateway) |
|
40 | |||
41 | /** |
||
42 | * @Route("/stats/", name="status.index") |
||
43 | */ |
||
44 | 2 | public function index() : array |
|
45 | { |
||
46 | 2 | $stats = $this->stats->getAll(); |
|
47 | |||
48 | try { |
||
49 | 2 | $redisStats = $this->getRedis()->info(); |
|
50 | 1 | } catch (PredisException $e) { |
|
51 | 1 | $redisStats = []; |
|
52 | } |
||
53 | |||
54 | return [ |
||
55 | 2 | 'jobs' => $this->messageQueue->getEventsByType(), |
|
56 | 2 | 'stats' => $stats, |
|
57 | 2 | 'redis' => $redisStats |
|
58 | ]; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @Route("/stats/reset/", methods="POST", name="stats.reset") |
||
63 | * @param Request $request |
||
64 | * @return bool |
||
65 | */ |
||
66 | 1 | public function resetStats(Request $request) : bool |
|
73 | } |
||
74 |