Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var CONFIG = {

// Load balancing pattern
// As of now a few are builtin
// random, roundrobin, sticky
// random, roundrobin
pattern: 'roundrobin'
}
],
Expand Down
3 changes: 2 additions & 1 deletion lib/balancers/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var _ = require('underscore');

// Random Pattern
function random(backends, req, cb) {
return cb(null, _.sample(backends));
var randomArrayIndex = _.random(1, backends.length) - 1;
return cb(null, backends[randomArrayIndex]);
}


Expand Down
2 changes: 1 addition & 1 deletion test/balancer-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var CONFIG = {

// Load balancing pattern
// As of now a few are builtin
// random, roundrobin, sticky
// random, roundrobin
balancer: function(backends, req, cb) {
// Fail first
cb(new Error('Failed balancing because of whatever'));
Expand Down
2 changes: 1 addition & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ var CONFIG = {

// Load balancing pattern
// As of now a few are builtin
// random, roundrobin, sticky
balancer: loadfire.balancers.roundrobin,
// random, roundrobin

middleware: [
function(req, res, next) {
Expand Down
2 changes: 1 addition & 1 deletion test/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var CONFIG = {

// Load balancing pattern
// As of now a few are builtin
// random, roundrobin, sticky
// random, roundrobin
balancer: loadfire.balancers.roundrobin,

middleware: [
Expand Down
2 changes: 1 addition & 1 deletion test/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var CONFIG = {

// Load balancing pattern
// As of now a few are builtin
// random, roundrobin, sticky
// random, roundrobin
balancer: function(backends, req, cb) {
return cb(null, {
host: 'localhost',
Expand Down