Просмотр исходного кода

add setting so that double flush is the default

can be disabled to stop flushing to track-changes
Brian Gough 6 лет назад
Родитель
Сommit
ad19fee667

+ 1 - 1
services/document-updater/app/coffee/HistoryManager.coffee

@@ -16,7 +16,7 @@ module.exports = HistoryManager =
 			if err?
 				logger.warn {err, doc_id}, "error getting history type"
 				# if there's an error continue and flush to track-changes for safety
-			if projectHistoryType is "project-history"
+			if Settings.disableDoubleFlush and projectHistoryType is "project-history"
 				logger.debug {doc_id, projectHistoryType}, "skipping track-changes flush"
 			else
 				metrics.inc 'history-flush', 1, { status: 'track-changes'}

+ 2 - 0
services/document-updater/config/settings.defaults.coffee

@@ -93,3 +93,5 @@ module.exports =
 	continuousBackgroundFlush: process.env['CONTINUOUS_BACKGROUND_FLUSH'] or false
 
 	smoothingOffset: process.env['SMOOTHING_OFFSET'] or 1000 # milliseconds
+
+	disableDoubleFlush: process.env['DISABLE_DOUBLE_FLUSH'] or false # don't flush track-changes for projects using project-history

+ 13 - 1
services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee

@@ -39,16 +39,28 @@ describe "HistoryManager", ->
 					.calledWith("#{@Settings.apis.trackchanges.url}/project/#{@project_id}/doc/#{@doc_id}/flush")
 					.should.equal true
 
-		describe "when the project uses project history", ->
+		describe "when the project uses project history and double flush is not disabled", ->
 			beforeEach ->
 				@RedisManager.getHistoryType = sinon.stub().yields(null, 'project-history')
 				@HistoryManager.flushDocChangesAsync @project_id, @doc_id
 
+			it "should send a request to the track changes api", ->
+				@request.post
+					.called
+					.should.equal true
+
+		describe "when the project uses project history and double flush is disabled", ->
+			beforeEach ->
+				@Settings.disableDoubleFlush = true
+				@RedisManager.getHistoryType = sinon.stub().yields(null, 'project-history')
+				@HistoryManager.flushDocChangesAsync @project_id, @doc_id
+
 			it "should not send a request to the track changes api", ->
 				@request.post
 					.called
 					.should.equal false
 
+
 	describe "flushProjectChangesAsync", ->
 		beforeEach ->
 			@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)