add withLock to processUncompressedUpdatesForDoc

This commit is contained in:
Brian Gough 2017-03-22 16:16:04 +00:00
parent 0dd668416d
commit b1c0ebbaae
2 changed files with 6 additions and 6 deletions

View file

@ -118,11 +118,11 @@ module.exports = UpdatesManager =
processUncompressedUpdatesWithLock: (project_id, doc_id, callback = (error) ->) -> processUncompressedUpdatesWithLock: (project_id, doc_id, callback = (error) ->) ->
UpdatesManager._prepareProjectForUpdates project_id, (error, temporary) -> UpdatesManager._prepareProjectForUpdates project_id, (error, temporary) ->
return callback(error) if error? return callback(error) if error?
UpdatesManager._processUncompressedUpdatesForDoc project_id, doc_id, temporary, callback UpdatesManager._processUncompressedUpdatesForDocWithLock project_id, doc_id, temporary, callback
# Process updates for a doc when the whole project is flushed (internal method) # Process updates for a doc when the whole project is flushed (internal method)
_processUncompressedUpdatesForDoc: (project_id, doc_id, temporary, callback = (error) ->) -> _processUncompressedUpdatesForDocWithLock: (project_id, doc_id, temporary, callback = (error) ->) ->
UpdatesManager._prepareDocForUpdates project_id, doc_id, (error) -> UpdatesManager._prepareDocForUpdates project_id, doc_id, (error) ->
return callback(error) if error? return callback(error) if error?
LockManager.runWithLock( LockManager.runWithLock(
@ -141,7 +141,7 @@ module.exports = UpdatesManager =
for doc_id in doc_ids for doc_id in doc_ids
do (doc_id) -> do (doc_id) ->
jobs.push (cb) -> jobs.push (cb) ->
UpdatesManager._processUncompressedUpdatesForDoc project_id, doc_id, temporary, cb UpdatesManager._processUncompressedUpdatesForDocWithLock project_id, doc_id, temporary, cb
async.parallelLimit jobs, 5, callback async.parallelLimit jobs, 5, callback
getDocUpdates: (project_id, doc_id, options = {}, callback = (error, updates) ->) -> getDocUpdates: (project_id, doc_id, options = {}, callback = (error, updates) ->) ->

View file

@ -317,7 +317,7 @@ describe "UpdatesManager", ->
@doc_ids = ["mock-id-1", "mock-id-2"] @doc_ids = ["mock-id-1", "mock-id-2"]
@UpdateTrimmer.shouldTrimUpdates = sinon.stub().callsArgWith(1, null, @temporary = "temp mock") @UpdateTrimmer.shouldTrimUpdates = sinon.stub().callsArgWith(1, null, @temporary = "temp mock")
@MongoManager.backportProjectId = sinon.stub().callsArg(2) @MongoManager.backportProjectId = sinon.stub().callsArg(2)
@UpdatesManager._processUncompressedUpdatesForDoc = sinon.stub().callsArg(3) @UpdatesManager._processUncompressedUpdatesForDocWithLock = sinon.stub().callsArg(3)
@RedisManager.getDocIdsWithHistoryOps = sinon.stub().callsArgWith(1, null, @doc_ids) @RedisManager.getDocIdsWithHistoryOps = sinon.stub().callsArgWith(1, null, @doc_ids)
@UpdatesManager.processUncompressedUpdatesForProject @project_id, () => @UpdatesManager.processUncompressedUpdatesForProject @project_id, () =>
@callback() @callback()
@ -330,7 +330,7 @@ describe "UpdatesManager", ->
it "should process the doc ops for the each doc_id", -> it "should process the doc ops for the each doc_id", ->
for doc_id in @doc_ids for doc_id in @doc_ids
@UpdatesManager._processUncompressedUpdatesForDoc @UpdatesManager._processUncompressedUpdatesForDocWithLock
.calledWith(@project_id, doc_id, @temporary) .calledWith(@project_id, doc_id, @temporary)
.should.equal true .should.equal true