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\Counter\InMemoryCounter;
use Orangesoft\Throttler\Collection\NodeInterface;
use Orangesoft\Throttler\Collection\Node;
use Orangesoft\Throttler\WeightedRoundRobinThrottler;
$throttler = new WeightedRoundRobinThrottler(
new InMemoryCounter(),
);
$collection = new InMemoryCollection([
new Node('192.168.0.1', 5),
new Node('192.168.0.2', 1),
new Node('192.168.0.3', 1),
]);
while (true) {
/** @var NodeInterface $node */
$node = $throttler->pick($collection);
// ...
}