Call all compound limiters on failure and added IO blocking

This commit is contained in:
Wouter de Jong 2020-09-30 12:10:13 +02:00
parent aa661492d2
commit 0279f88e6c
2 changed files with 5 additions and 4 deletions

View File

@ -37,10 +37,6 @@ final class CompoundLimiter implements LimiterInterface
foreach ($this->limiters as $limiter) {
$limit = $limiter->consume($tokens);
if (0 === $limit->getRemainingTokens()) {
return $limit;
}
if (null === $minimalLimit || $limit->getRemainingTokens() < $minimalLimit->getRemainingTokens()) {
$minimalLimit = $limit;
}

View File

@ -43,4 +43,9 @@ class Limit
{
return $this->availableTokens;
}
public function wait(): void
{
sleep(($this->retryAfter->getTimestamp() - time()) * 1e6);
}
}