mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 13:42:21 -05:00
Merge branch 'ho-drain-connections-timewindow' of github.com:overleaf/real-time into ho-drain-connections-timewindow
This commit is contained in:
commit
2ae4c8c174
2 changed files with 3 additions and 4 deletions
|
@ -4,7 +4,7 @@ module.exports = DrainManager =
|
||||||
|
|
||||||
startDrainTimeWindow: (io, minsToDrain)->
|
startDrainTimeWindow: (io, minsToDrain)->
|
||||||
drainPerMin = io.sockets.clients().length / 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) ->
|
startDrain: (io, rate) ->
|
||||||
# Clear out any old interval
|
# Clear out any old interval
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe "DrainManager", ->
|
||||||
describe "startDrainTimeWindow", ->
|
describe "startDrainTimeWindow", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@clients = []
|
@clients = []
|
||||||
for i in [0..1619]
|
for i in [0..5399]
|
||||||
@clients[i] = {
|
@clients[i] = {
|
||||||
id: i
|
id: i
|
||||||
emit: sinon.stub()
|
emit: sinon.stub()
|
||||||
|
@ -25,8 +25,7 @@ describe "DrainManager", ->
|
||||||
|
|
||||||
it "should set a drain rate fast enough", (done)->
|
it "should set a drain rate fast enough", (done)->
|
||||||
@DrainManager.startDrainTimeWindow(@io, 9)
|
@DrainManager.startDrainTimeWindow(@io, 9)
|
||||||
console.log(@DrainManager.startDrain.args[0])
|
@DrainManager.startDrain.calledWith(@io, 10).should.equal true
|
||||||
@DrainManager.startDrain.calledWith(@io, 3).should.equal true
|
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue