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:
parent
20d5cc69a4
commit
74db743ffa
2 changed files with 9 additions and 2 deletions
services/real-time/app/coffee
|
@ -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
|
Loading…
Add table
Reference in a new issue