https://github.com/php-http/throttle-plugin
PHP-HTTP plugin for throttling/rate limiting with the symfony/rate-limiter
https://github.com/php-http/throttle-plugin
Last synced: 9 months ago
JSON representation
PHP-HTTP plugin for throttling/rate limiting with the symfony/rate-limiter
- Host: GitHub
- URL: https://github.com/php-http/throttle-plugin
- Owner: php-http
- License: mit
- Created: 2022-02-23T10:56:00.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-14T14:46:42.000Z (over 1 year ago)
- Last Synced: 2024-09-16T07:45:22.031Z (over 1 year ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 2
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Throttle Plugin
PHP-HTTP plugin for throttling/rate limiting with the [symfony/rate-limiter](https://symfony.com/doc/current/rate_limiter.html)
> Warning: Plugin currently utilizes usleep() and hence is blocking whole process while waiting
## Install
Via [Composer](https://getcomposer.org/doc/00-intro.md)
```bash
composer require php-http/throttle-plugin
```
## Usage
```php
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](LICENSE) for more information.