Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47af76f

Browse files
committed
[RateLimiter] Allow configuration value "no_limit"
1 parent 508ec9c commit 47af76f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,14 +1846,14 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode)
18461846
->enumNode('strategy')
18471847
->info('The rate limiting algorithm to use for this rate')
18481848
->isRequired()
1849-
->values(['fixed_window', 'token_bucket', 'sliding_window'])
1849+
->values(['fixed_window', 'token_bucket', 'sliding_window', 'no_limit'])
18501850
->end()
18511851
->integerNode('limit')
18521852
->info('The maximum allowed hits in a fixed interval or burst')
18531853
->isRequired()
18541854
->end()
18551855
->scalarNode('interval')
1856-
->info('Configures the fixed interval if "strategy" is set to "fixed_window" or "sliding_window". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
1856+
->info('Configures the fixed interval if "strategy" is set to "fixed_window", "sliding_window" or "no_limit". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
18571857
->end()
18581858
->arrayNode('rate')
18591859
->info('Configures the fill rate if "strategy" is set to "token_bucket"')

src/Symfony/Component/RateLimiter/RateLimiter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ public function create(?string $key = null): LimiterInterface
5454
case 'sliding_window':
5555
return new SlidingWindowLimiter($id, $this->config['limit'], $this->config['interval'], $this->storage, $lock);
5656

57+
case 'no_limit':
58+
return new NoLimiter();
59+
5760
default:
58-
throw new \LogicException(sprintf('Limiter strategy "%s" does not exists, it must be either "token_bucket", "sliding_window" or "fixed_window".', $this->config['strategy']));
61+
throw new \LogicException(sprintf('Limiter strategy "%s" does not exists, it must be either "token_bucket", "sliding_window", "fixed_window" or "no_limit".', $this->config['strategy']));
5962
}
6063
}
6164

0 commit comments

Comments
 (0)