php-http / throttle-plugin
HTTPlug 的限流/请求限制插件
1.1.0
2024-06-14 14:42 UTC
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 插件,用于与 symfony/rate-limiter 进行限流/速率限制
警告:插件目前使用 usleep(),因此在等待时将阻塞整个进程
安装
通过 Composer
composer require php-http/throttle-plugin
用法
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(), );
许可
MIT 许可。有关更多信息,请参阅许可文件。