Skip to content

Commit 0279f88

Browse files
committed
Call all compound limiters on failure and added IO blocking
1 parent aa66149 commit 0279f88

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Symfony/Component/RateLimiter/CompoundLimiter.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public function consume(int $tokens = 1): Limit
3737
foreach ($this->limiters as $limiter) {
3838
$limit = $limiter->consume($tokens);
3939

40-
if (0 === $limit->getRemainingTokens()) {
41-
return $limit;
42-
}
43-
4440
if (null === $minimalLimit || $limit->getRemainingTokens() < $minimalLimit->getRemainingTokens()) {
4541
$minimalLimit = $limit;
4642
}

src/Symfony/Component/RateLimiter/Limit.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ public function getRemainingTokens(): int
4343
{
4444
return $this->availableTokens;
4545
}
46+
47+
public function wait(): void
48+
{
49+
sleep(($this->retryAfter->getTimestamp() - time()) * 1e6);
50+
}
4651
}

0 commit comments

Comments
 (0)