UNPKG

619 BJavaScriptView Raw
1
2/**
3 * PoolSelector
4 */
5var PoolSelector = module.exports = {};
6
7PoolSelector.RR = function PoolSelectorRoundRobin() {
8 var index = 0;
9
10 return function(clusterIds) {
11 if (index >= clusterIds.length) {
12 index = 0;
13 }
14
15 var clusterId = clusterIds[index++];
16
17 return clusterId;
18 };
19};
20
21PoolSelector.RANDOM = function PoolSelectorRandom() {
22 return function(clusterIds) {
23 return clusterIds[Math.floor(Math.random() * clusterIds.length)];
24 };
25};
26
27PoolSelector.ORDER = function PoolSelectorOrder() {
28 return function(clusterIds) {
29 return clusterIds[0];
30 };
31};