https://github.com/gowork/throttler
Simple PHP execution throttler.
https://github.com/gowork/throttler
php throttle throttler throttling
Last synced: 3 months ago
JSON representation
Simple PHP execution throttler.
- Host: GitHub
- URL: https://github.com/gowork/throttler
- Owner: gowork
- License: mit
- Created: 2019-12-16T20:14:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-28T22:10:15.000Z (over 4 years ago)
- Last Synced: 2025-07-04T02:05:22.205Z (4 months ago)
- Topics: php, throttle, throttler, throttling
- Language: PHP
- Size: 14.6 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Throttler
[](https://travis-ci.org/gowork/throttler)
Use the throttle to control the speed.
```php
use GW\Throttler\Throttler;$throttler = new Throttler(1.0);
foreach ($heavyTasks->all() as $task) {
$throttler->throttle(); // wait a second... before next task
$task->run();
}
```Alternative usage for wrapping iterables:
```php
use GW\Throttler\Throttler;$throttledTask = Throttler::iterable($heavyTasks->all(), 1.0);
foreach ($throttledTask as $task) {
$task->run(); // for each iteration it will sleep one second
}
```