mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge branch 'ho-drain-connections-timewindow' of github.com:overleaf/real-time into ho-drain-connections-timewindow
This commit is contained in:
@@ -4,7 +4,7 @@ module.exports = DrainManager =
|
||||
|
||||
startDrainTimeWindow: (io, minsToDrain)->
|
||||
drainPerMin = io.sockets.clients().length / minsToDrain
|
||||
DrainManager.startDrain(io, drainPerMin / 60)
|
||||
DrainManager.startDrain(io, Math.max(drainPerMin / 60, 4)) # enforce minimum drain rate
|
||||
|
||||
startDrain: (io, rate) ->
|
||||
# Clear out any old interval
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "DrainManager", ->
|
||||
describe "startDrainTimeWindow", ->
|
||||
beforeEach ->
|
||||
@clients = []
|
||||
for i in [0..1619]
|
||||
for i in [0..5399]
|
||||
@clients[i] = {
|
||||
id: i
|
||||
emit: sinon.stub()
|
||||
@@ -25,8 +25,7 @@ describe "DrainManager", ->
|
||||
|
||||
it "should set a drain rate fast enough", (done)->
|
||||
@DrainManager.startDrainTimeWindow(@io, 9)
|
||||
console.log(@DrainManager.startDrain.args[0])
|
||||
@DrainManager.startDrain.calledWith(@io, 3).should.equal true
|
||||
@DrainManager.startDrain.calledWith(@io, 10).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user