Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
bug fixes to weighted_score plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarraford committed Dec 18, 2014
1 parent 4b01666 commit d5f74e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lua/src/lib/plugins/weighted_score.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ M.balance = function(request, session, param)
end
local rand = math.random(1, available_score)
if param == 'least' then
local first_server_score = (max_score - servers[1]['score'])
first_server_score = (max_score - servers[1]['score'])
else
local first_server_score = servers[1]['score']
first_server_score = servers[1]['score']
end
if rand <= first_server_score then
return servers[1]
Expand All @@ -43,8 +43,8 @@ M.balance = function(request, session, param)
if most_score == nil or s['score'] > most_score then
most_score = s['score']
end
if least_score == nil or up['score'] < least_score then
least_score = up['score']
if least_score == nil or s['score'] < least_score then
least_score = s['score']
end
if param == 'least' then
do
Expand Down
8 changes: 4 additions & 4 deletions src/lib/plugins/weighted_score.moon
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ M.balance = (request, session, param) ->
-- pick random number within total available score
rand = math.random( 1, available_score )
if param == 'least'
first_server_score = (max_score - servers[1]['score'])
export first_server_score = (max_score - servers[1]['score'])
else
first_server_score = servers[1]['score']
export first_server_score = servers[1]['score']
if rand <= first_server_score
return servers[1]
else
Expand All @@ -63,8 +63,8 @@ M.balance = (request, session, param) ->
for s in *servers
if most_score == nil or s['score'] > most_score
most_score = s['score']
if least_score == nil or up['score'] < least_score
least_score = up['score']
if least_score == nil or s['score'] < least_score
least_score = s['score']
if param == 'least'
available_upstreams = [ s for s in *servers when s['score'] < most_score ]
else
Expand Down

0 comments on commit d5f74e9

Please sign in to comment.