We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Something like this would come in handy:
<?php declare(strict_types = 1); use Github\Api\RateLimit\RateLimitResource; use Github\Client; use Http\Client\Common\Plugin; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; class RateLimitPlugin implements Plugin { private Client $client; public function setClient(Client $client): void { $this->client = $client; } public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $path = $request->getUri()->getPath(); if ($path === '/rate_limit') { return $next($request); } /** @var RateLimitResource $resource */ $resource = $this->client->api('rate_limit')->getResource('core'); if ($resource->getRemaining() < 10) { $reset = $resource->getReset(); $sleepFor = $reset - time(); if ($sleepFor > 0) { sleep($sleepFor); } } return $next($request); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Something like this would come in handy:
The text was updated successfully, but these errors were encountered: