add setting so that double flush is the default

can be disabled to stop flushing to track-changes
This commit is contained in:
Brian Gough 2019-11-25 13:36:25 +00:00
parent 4f6583bbf2
commit ad19fee667
3 changed files with 16 additions and 2 deletions

View file

@ -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'}

View file

@ -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

View file

@ -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)