From 63f052192e2cb31b45cf0656b4d21d0c95a8b62e Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 3 Jun 2019 09:42:12 +0100 Subject: [PATCH 1/3] use background flush on disconnect --- services/real-time/app/coffee/DocumentUpdaterManager.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/real-time/app/coffee/DocumentUpdaterManager.coffee b/services/real-time/app/coffee/DocumentUpdaterManager.coffee index 9f516c2f2d..d5df28ed49 100644 --- a/services/real-time/app/coffee/DocumentUpdaterManager.coffee +++ b/services/real-time/app/coffee/DocumentUpdaterManager.coffee @@ -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? From 973a25fc644ea885355f5bdc33368cccacea192e Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 3 Jun 2019 10:33:32 +0100 Subject: [PATCH 2/3] fix background flush unit test --- .../test/unit/coffee/DocumentUpdaterManagerTests.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee index 4f2c5d9b51..e6d82f24ff 100644 --- a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee +++ b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee @@ -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", -> From 40f3456b1c4c82b166dba6cff71bc2e48fd28a7c Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 3 Jun 2019 10:34:59 +0100 Subject: [PATCH 3/3] update unit test --- .../test/unit/coffee/DocumentUpdaterManagerTests.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee index 4f2c5d9b51..e6d82f24ff 100644 --- a/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee +++ b/services/real-time/test/unit/coffee/DocumentUpdaterManagerTests.coffee @@ -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", ->