Merge pull request #54 from overleaf/bg-use-background-flush-on-disconnect

use background flush on disconnect
This commit is contained in:
Brian Gough 2019-06-03 10:53:43 +01:00 committed by GitHub
commit 9da98614c7
2 changed files with 4 additions and 2 deletions

View file

@ -36,9 +36,11 @@ module.exports = DocumentUpdaterManager =
callback err
flushProjectToMongoAndDelete: (project_id, callback = ()->) ->
# this method is called when the last connected user leaves the project
logger.log project_id:project_id, "deleting project from document updater"
timer = new metrics.Timer("delete.mongo.project")
url = "#{settings.apis.documentupdater.url}/project/#{project_id}"
# flush the project in the background when all users have left
url = "#{settings.apis.documentupdater.url}/project/#{project_id}?background=true"
request.del url, (err, res, body)->
timer.done()
if err?

View file

@ -93,7 +93,7 @@ describe 'DocumentUpdaterManager', ->
@DocumentUpdaterManager.flushProjectToMongoAndDelete @project_id, @callback
it 'should delete the project from the document updater', ->
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}"
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}?background=true"
@request.del.calledWith(url).should.equal true
it "should call the callback with no error", ->