1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-11 02:37:21 +00:00

allow fractional drain rate

This commit is contained in:
Brian Gough 2019-05-24 15:23:01 +01:00
parent 20d5cc69a4
commit 74db743ffa
2 changed files with 9 additions and 2 deletions
services/real-time/app/coffee

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