Initial prototype

This commit is contained in:
delvedor
2018-10-18 17:27:31 +02:00
parent 7dbb9214d2
commit e1b80882af
8 changed files with 653 additions and 0 deletions

23
lib/Selectors.js Normal file
View File

@ -0,0 +1,23 @@
'use strict'
class RoundRobinSelector {
constructor () {
this.current = -1
}
select (connections) {
if (++this.current >= connections.length) {
this.current = 0
}
return connections[this.current]
}
}
class RandomSelector {
select (connections) {
const index = Math.floor(Math.random() * connections.length)
return connections[index]
}
}
module.exports = { RoundRobinSelector, RandomSelector }