openresty / lua-resty-balancer

A generic consistent hash implementation for OpenResty/Lua
322 stars 77 forks source link

feat: add nginx swrr support #49

Closed jizhuozhi closed 1 year ago

jizhuozhi commented 1 year ago

Hello, @doujiang24 . According to #44 , I create a new PR with nginx swrr implementation, PLAT.

zhuizhuhaomeng commented 1 year ago

merged with small modifications.

diff --git a/lib/resty/swrr.lua b/lib/resty/swrr.lua
index 591b6a6..7f281c1 100644
--- a/lib/resty/swrr.lua
+++ b/lib/resty/swrr.lua
@@ -125,7 +125,7 @@ local function find(self)
         total = total + weight
         current_weight = current_weight + weight
         current_weights[id] = current_weight
-        
+
         if best_id == nil or best_current_weight < current_weight then
             best_id = id
             best_current_weight = current_weight
zhuizhuhaomeng commented 1 year ago

@jizhuozhi

Thank you for your contribution. After I merged this PR, I found we need to add some description to the doc. Would please add the doc about the swrr?

https://github.com/openresty/lua-resty-balancer/blob/master/README.markdown#name

jizhuozhi commented 1 year ago

Would please add the doc about the swrr?

Of course, I will do it latter