bentools/funnel-http-client

为 symfony/http-client 提供速率限制处理器的节流器

1.0 2023-02-15 10:00 UTC

This package is auto-updated.

Last update: 2024-09-15 13:26:28 UTC


README

Latest Stable Version License Build Status Coverage Status Quality Score Total Downloads

🚦 Funnel Http Client

用于对受到速率限制的请求进行节流的 symfony/http-client 装饰器。

安装

composer require bentools/funnel-http-client:1.0.x-dev

使用

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

测试

./vendor/bin/phpunit

许可证

MIT.