wpjscc / reactphp-request-limiter
v1.0.0
2023-11-09 10:43 UTC
Requires
- evenement/evenement: ^3.0
- wpjscc/reactphp-limiter: ^1.0
Requires (Dev)
- phpunit/phpunit: ^10.4
This package is auto-updated.
Last update: 2024-11-09 12:57:50 UTC
README
install
composer require reactphp-request-limiter -vvv
Usage
require __DIR__ . '/vendor/autoload.php'; use Wpjscc\Request\Limiter; // 10 request per second, when third parameter is true, it will be queue to handle $limiter = new Limiter(10, 1000, false); $limiter->on('data', function ($key, $data) { echo $key . ' is completed ' . PHP_EOL; }); for ($i=0; $i < 100; $i++) { $limiter->addHandle($i, function () { return \React\Promise\resolve(true); }); }
tests
./vendor/bin/phpunit tests