Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 904 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 904 Bytes

LoadBalance Build Status

Installation

Simply add a dependency on wueason/loadbalance to your project's composer.json file if you use Composer to manage the dependencies of your project.

Here is a minimal example of a composer.json file that just defines a dependency on LoadBalance:

{
    "require": {
        "wueason/loadbalance": "^1.0"
    }
}

Usage Examples

Creating a LoadBalance object and pick a random instance

use Wueason\Loadbalance\RandomEngine;
use Wueason\Loadbalance\BaseInstance;

// Create Loadbalance object with BaseInstance
$pool = array_map(function($a){
            return new BaseInstance($a);
        }, ['A','B','C']);
$lb = new RandomEngine($pool);

// Get the random instance
print $lb->pick();