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

Skip to content

Commit 58f4e9d

Browse files
committed
bug #38665 [RateLimiter] Allow configuration value "no_limit" (Nyholm)
This PR was squashed before being merged into the 5.x branch. Discussion ---------- [RateLimiter] Allow configuration value "no_limit" | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | maybe? | New feature? | not sure | Deprecations? | | Tickets | | License | MIT | Doc PR | I dont see any reason why we should allow people to configure "no_limit". I assume this was just forgotten. Commits ------- 2b9058d [RateLimiter] Allow configuration value "no_limit"
2 parents 6bb46de + 2b9058d commit 58f4e9d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ 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')

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)