Merge pull request #55 from overleaf/bg-allow-fractional-drain-rate

allow fractional drain rate
This commit is contained in:
Brian Gough 2019-06-03 10:53:57 +01:00 committed by GitHub
commit d4f003fe0f
2 changed files with 9 additions and 2 deletions

View file

@ -6,9 +6,16 @@ module.exports =
clearInterval @interval
if rate == 0
return
else if rate < 1
# allow lower drain rates
# e.g. rate=0.1 will drain one client every 10 seconds
pollingInterval = 1000 / rate
rate = 1
else
pollingInterval = 1000
@interval = setInterval () =>
@reconnectNClients(io, rate)
, 1000
, pollingInterval
RECONNECTED_CLIENTS: {}
reconnectNClients: (io, N) ->

View file

@ -15,7 +15,7 @@ module.exports = HttpApiController =
startDrain: (req, res, next) ->
io = req.app.get("io")
rate = req.query.rate or "4"
rate = parseInt(rate, 10)
rate = parseFloat(rate) || 0
logger.log {rate}, "setting client drain rate"
DrainManager.startDrain io, rate
res.send 204