php-http/throttle-plugin

Throttle/request limiter plugin for HTTPlug

1.0.0 2022-02-23 14:58 UTC

This package is auto-updated.

Last update: 2024-04-17 14:37:03 UTC


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.