Skip to content

Commit

Permalink
Allow to configure request watchers priority (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
marmichalski committed Feb 23, 2021
1 parent ee6f89b commit e689e39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/DependencyInjection/ChaosMonkeyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
]);
}
}
}
7 changes: 6 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e689e39

Please sign in to comment.