php-http / throttle-plugin
Throttle/request limiter plugin for HTTPlug
Installs: 5 660
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 2
Open Issues: 1
Requires
- php: >=7.4
- php-http/client-common: >=1.3
- symfony/rate-limiter: >=5.4
Requires (Dev)
- nyholm/psr7: ^1.0
- php-http/mock-client: ^1.4
- phpunit/phpunit: ^9.6
- psr/http-factory: ^1.1
- ramsey/coding-standard: ^2.0
- symfony/phpunit-bridge: >=6.0
README
PHP-HTTP plugin for throttling/rate limiting with the symfony/rate-limiter
Warning: Plugin currently utilizes usleep() and hence is blocking whole process while waiting
Install
Via Composer
composer require php-http/throttle-plugin
Usage
new \Http\Client\Common\Plugin\ThrottlePlugin( (new \Symfony\Component\RateLimiter\RateLimiterFactory( ['id' => 'foo', 'policy' => 'fixed_window', 'limit' => 2, 'interval' => '3 seconds'], new \Symfony\Component\RateLimiter\Storage\InMemoryStorage(), ))->create(), );
Licensing
MIT license. Please see License File for more information.