1 |
|
2 |
|
3 |
|
4 |
|
5 | var PoolSelector = module.exports = {};
|
6 |
|
7 | PoolSelector.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 |
|
21 | PoolSelector.RANDOM = function PoolSelectorRandom() {
|
22 | return function(clusterIds) {
|
23 | return clusterIds[Math.floor(Math.random() * clusterIds.length)];
|
24 | };
|
25 | };
|
26 |
|
27 | PoolSelector.ORDER = function PoolSelectorOrder() {
|
28 | return function(clusterIds) {
|
29 | return clusterIds[0];
|
30 | };
|
31 | };
|