mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
retrieve rabbitmq configuration from configuration.yml
This commit is contained in:
@@ -32,11 +32,12 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
$app['alchemy_queues.queues'] = $app->share(function (Application $app) {
|
$app['alchemy_queues.queues'] = $app->share(function (Application $app) {
|
||||||
$defaultConfiguration = [
|
$defaultConfiguration = [
|
||||||
'worker-queue' => [
|
'worker-queue' => [
|
||||||
'registry' => 'alchemy_worker.queue_registry',
|
'registry' => 'alchemy_worker.queue_registry',
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
'port' => 5672,
|
'port' => 5672,
|
||||||
'user' => 'guest',
|
'user' => 'guest',
|
||||||
'vhost' => '/'
|
'password' => 'guest',
|
||||||
|
'vhost' => '/'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -46,19 +47,22 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
|
|
||||||
$queueConfigurations = $configuration->get(['workers', 'queue'], $defaultConfiguration);
|
$queueConfigurations = $configuration->get(['workers', 'queue'], $defaultConfiguration);
|
||||||
|
|
||||||
$queueConfiguration = reset($queueConfigurations);
|
$config = [];
|
||||||
$queueKey = key($queueConfigurations);
|
|
||||||
|
|
||||||
if (! isset($queueConfiguration['name'])) {
|
foreach($queueConfigurations as $name => $queueConfiguration) {
|
||||||
if (! is_string($queueKey)) {
|
$queueKey = $name;
|
||||||
throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.');
|
|
||||||
|
if (! isset($queueConfiguration['name'])) {
|
||||||
|
if (! is_string($queueKey)) {
|
||||||
|
throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$queueConfiguration['name'] = $queueKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queueConfiguration['name'] = $queueKey;
|
$config[$queueConfiguration['name']] = $queueConfiguration ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = [ $queueConfiguration['name'] => $queueConfiguration ];
|
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
catch (RuntimeException $exception) {
|
catch (RuntimeException $exception) {
|
||||||
|
Reference in New Issue
Block a user