From e689e39c1397bb823cbe34eee1b0d835a5d760f4 Mon Sep 17 00:00:00 2001 From: Marcin Michalski Date: Tue, 23 Feb 2021 18:37:51 +0000 Subject: [PATCH] Allow to configure request watchers priority (#5) --- README.md | 4 +++- src/DependencyInjection/ChaosMonkeyExtension.php | 7 +++++-- src/DependencyInjection/Configuration.php | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ffa6fcd..d68d6f2 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ chaos_monkey: kill_app: active: false watchers: # currently watchers can be enabled/disabled only in container compile time - request: true + request: + enabled: true + priority: 0 ``` ## Roadmap diff --git a/src/DependencyInjection/ChaosMonkeyExtension.php b/src/DependencyInjection/ChaosMonkeyExtension.php index 0a45b44..8f802c6 100644 --- a/src/DependencyInjection/ChaosMonkeyExtension.php +++ b/src/DependencyInjection/ChaosMonkeyExtension.php @@ -44,9 +44,12 @@ private function setChaosMonkeySettings(ContainerBuilder $container, array $conf private function enableWatchers(ContainerBuilder $container, array $config): void { - if ($config['watchers']['request'] === true) { + if ($config['watchers']['request']['enabled'] === true) { $requestWatcher = $container->getDefinition('chaos_monkey.watcher.request'); - $requestWatcher->addTag('kernel.event_listener', ['event' => 'kernel.request']); + $requestWatcher->addTag('kernel.event_listener', [ + 'event' => 'kernel.request', + 'priority' => $config['watchers']['request']['priority'], + ]); } } } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2e533ed..d9c6807 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -57,7 +57,12 @@ public function getConfigTreeBuilder() ->arrayNode('watchers') ->addDefaultsIfNotSet() ->children() - ->booleanNode('request')->defaultTrue()->end() + ->arrayNode('request') + ->canBeDisabled() + ->children() + ->integerNode('priority')->defaultValue(0)->end() + ->end() + ->end() ->end() ->end() ->end();