1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
QueueConfigRegistry.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Main\Messenger\Internals\Config;
6
7use Bitrix\Main\Config\Configuration;
8use Bitrix\Main\Config\ConfigurationException;
9use Bitrix\Main\Messenger\Internals\Retry\MultiplierRetryStrategy;
10use Bitrix\Main\Messenger\Internals\Retry\RetryStrategyInterface;
11use Bitrix\Main\ModuleManager;
12
14{
18 private array $queues = [];
19
23 public function __construct()
24 {
25 $config = Configuration::getValue('messenger');
26
27 if (!empty($config['queues']) && is_array($config['queues']))
28 {
29 $this->appendGlobalQueues($config['queues']);
30 }
31
33
34 foreach ($modules as $moduleId => $moduleData)
35 {
36 $settings = Configuration::getInstance($moduleId)->get('messenger');
37
38 if (!empty($settings['queues']) && is_array($settings['queues']))
39 {
40 $this->appendQueues($settings['queues'], $moduleId);
41 }
42 }
43 }
44
48 private function appendQueues(array $queues, string $moduleId): void
49 {
50 foreach ($queues as $queueId => $params)
51 {
52 $this->appendQueue($params, $queueId, $moduleId);
53 }
54 }
55
59 private function appendGlobalQueues(array $queues): void
60 {
61 foreach ($queues as $queueId => $params)
62 {
63 $this->appendQueue($params, $queueId, $params['module'] ?? 'main');
64 }
65 }
66
70 private function appendQueue(array $params, string $queueId, string $moduleId): void
71 {
72 if (empty($params['handler']))
73 {
74 throw new ConfigurationException(sprintf('Param "handler" should be set for the queue "%s"', $queueId));
75 }
76
77 $this->queues[$queueId] = new QueueConfig(
78 $queueId,
79 $params['handler'],
81 $params['broker'] ?? null,
82 $this->buildRetryStrategy($params)
83 );
84 }
85
89 public function getQueues(): array
90 {
91 return $this->queues;
92 }
93
94 public function getQueueConfig(string $queueId): ?QueueConfig
95 {
96 return $this->queues[$queueId] ?? null;
97 }
98
99 private function buildRetryStrategy(array $params): RetryStrategyInterface
100 {
101 if (!isset($params['retry_strategy']))
102 {
103 return new MultiplierRetryStrategy(3, 1000, 2);
104 }
105
106 $config = $params['retry_strategy'];
107
108 return new MultiplierRetryStrategy(
109 $config['max_retries'] ?? 3,
110 ($config['delay'] ?? 1) * 1000,
111 $config['multiplier'] ?? 2,
112 ($config['max_delay'] ?? 0) * 1000,
113 0
114 );
115 }
116}
static getInstalledModules()
Определения modulemanager.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$moduleId
$modules
Определения bitrix.php:26
$settings
Определения product_settings.php:43
$config
Определения quickway.php:69
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799