PHP code example of orangesoft / throttler
1. Go to this page and download the library: Download orangesoft/throttler library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
orangesoft / throttler example snippets
use Orangesoft\Throttler\Collection\Node;
use Orangesoft\Throttler\Collection\Collection;
use Orangesoft\Throttler\Strategy\WeightedRoundRobinStrategy;
use Orangesoft\Throttler\Strategy\InMemoryCounter;
use Orangesoft\Throttler\Throttler;
$throttler = new Throttler(
new WeightedRoundRobinStrategy(
new InMemoryCounter(start: 0),
)
);
$collection = new Collection([
new Node('node1', 5),
new Node('node2', 1),
new Node('node3', 1),
]);
while (true) {
/** @var Node $node */
$node = $throttler->pick($collection);
// ...
}