membphis commented on a change in pull request #2001:
URL: https://github.com/apache/apisix/pull/2001#discussion_r466332602
##########
File path: apisix/balancer/ewma.lua
##########
@@ -33,31 +34,34 @@ local ewma_lock, ewma_lock_err
local shm_ewma = ngx_shared.balancer_ewma
local shm_last_touched_at= ngx_shared.balancer_ewma_last_touched_at
+
local function lock(upstream)
local _, err = ewma_lock:lock(upstream .. LOCK_KEY)
if err then
if err ~= "timeout" then
- core.log.error("EWMA Balancer failed to lock:", tostring(err))
+ core.log.error("EWMA Balancer failed to lock:", err)
end
return false, err
end
+
return true
end
local function unlock()
local ok, err = ewma_lock:unlock()
if not ok then
- core.log.error("EWMA Balancer failed to unlock:", tostring(err))
+ core.log.error("EWMA Balancer failed to unlock:", err)
return false, err
end
+
return true
end
local function decay_ewma(ewma, last_touched_at, rtt, now)
local td = now - last_touched_at
- td = (td > 0) and td or 0
+ td = math.max(td, 0)
Review comment:
only one space, but got two spaces in `= math`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]