bentools / funnel-http-client
A throttler for symfony/http-client to handle rate limits
Installs: 8 767
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=8.0
- psr/log: ^1|^2|^3
- symfony/http-client: ~5.0|~6.0|^7.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.5
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ~3.7
- symfony/var-dumper: ~5.0
This package is auto-updated.
Last update: 2024-12-18 08:43:12 UTC
README
🚦 Funnel Http Client
A decorator for symfony/http-client to throttle requests subject to rate-limits.
Installation
composer require bentools/funnel-http-client:1.0.x-dev
Usage
use BenTools\FunnelHttpClient\FunnelHttpClient; use Symfony\Component\HttpClient\HttpClient; $client = FunnelHttpClient::throttle(HttpClient::create(), $maxRequests = 3, $timeWindow = 5); $client->request('GET', 'http://foo.bar'); $client->request('GET', 'http://foo.bar'); $client->request('GET', 'http://foo.bar'); $client->request('GET', 'http://foo.bar'); // Will wait a little before being actually triggered
Tests
./vendor/bin/phpunit
License
MIT.