gowork/throttler

Simple PHP execution throttler.

Maintainers

Package info

github.com/gowork/throttler

pkg:composer/gowork/throttler

Statistics

Installs: 11 634

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 1

0.2 2020-12-04 11:40 UTC

This package is auto-updated.

Last update: 2026-03-01 00:13:42 UTC


README

Build Status

Use the throttle to control the speed.

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:

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
}