Merge pull request #55 from overleaf/bg-allow-fractional-drain-rate
allow fractional drain rate
This commit is contained in:
@@ -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) ->
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user