diff --git a/services/web/app/coffee/infrastructure/LockManager.coffee b/services/web/app/coffee/infrastructure/LockManager.coffee index 370e4c09c9..3064fffabf 100644 --- a/services/web/app/coffee/infrastructure/LockManager.coffee +++ b/services/web/app/coffee/infrastructure/LockManager.coffee @@ -9,17 +9,17 @@ module.exports = LockManager = MAX_LOCK_WAIT_TIME: 10000 # 10s maximum time to spend trying to get the lock REDIS_LOCK_EXPIRY: 30 # seconds. Time until lock auto expires in redis. - _blockingKey : (key)-> "Blocking:"+key + _blockingKey : (key)-> "lock:web:{#{key}}" tryLock : (key, callback = (err, isFree)->)-> rclient.set LockManager._blockingKey(key), "locked", "EX", LockManager.REDIS_LOCK_EXPIRY, "NX", (err, gotLock)-> return callback(err) if err? if gotLock == "OK" - metrics.inc "doc-not-blocking" + metrics.inc "lock-not-blocking" callback err, true else - metrics.inc "doc-blocking" - logger.log key: key, redis_response: gotLock, "doc is locked" + metrics.inc "lock-blocking" + logger.log key: key, redis_response: gotLock, "lock is locked" callback err, false getLock: (key, callback = (error) ->) -> @@ -42,10 +42,10 @@ module.exports = LockManager = return callback(err) if err? exists = parseInt replys[0] if exists == 1 - metrics.inc "doc-blocking" + metrics.inc "lock-blocking" callback err, false else - metrics.inc "doc-not-blocking" + metrics.inc "lock-not-blocking" callback err, true releaseLock: (key, callback)-> diff --git a/services/web/test/UnitTests/coffee/infrastructure/LockManager/CheckingTheLock.coffee b/services/web/test/UnitTests/coffee/infrastructure/LockManager/CheckingTheLock.coffee index 8926382f8b..cf56778ec8 100644 --- a/services/web/test/UnitTests/coffee/infrastructure/LockManager/CheckingTheLock.coffee +++ b/services/web/test/UnitTests/coffee/infrastructure/LockManager/CheckingTheLock.coffee @@ -4,7 +4,7 @@ path = require('path') modulePath = path.join __dirname, '../../../../../app/js/infrastructure/LockManager.js' project_id = 1234 doc_id = 5678 -blockingKey = "Blocking:#{doc_id}" +blockingKey = "lock:web:{#{doc_id}}" SandboxedModule = require('sandboxed-module') describe 'LockManager - checking the lock', ()-> diff --git a/services/web/test/UnitTests/coffee/infrastructure/LockManager/ReleasingTheLock.coffee b/services/web/test/UnitTests/coffee/infrastructure/LockManager/ReleasingTheLock.coffee index fa99b87739..8ccab0a757 100644 --- a/services/web/test/UnitTests/coffee/infrastructure/LockManager/ReleasingTheLock.coffee +++ b/services/web/test/UnitTests/coffee/infrastructure/LockManager/ReleasingTheLock.coffee @@ -21,6 +21,6 @@ describe 'LockManager - releasing the lock', ()-> it 'should put a all data into memory', (done)-> LockManager.releaseLock doc_id, -> - deleteStub.calledWith("Blocking:#{doc_id}").should.equal true + deleteStub.calledWith("lock:web:{#{doc_id}}").should.equal true done() diff --git a/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee b/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee index a227ac60bd..5397e18cb2 100644 --- a/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee +++ b/services/web/test/UnitTests/coffee/infrastructure/LockManager/tryLockTests.coffee @@ -24,7 +24,7 @@ describe 'LockManager - trying the lock', -> @LockManager.tryLock @doc_id, @callback it "should set the lock key with an expiry if it is not set", -> - @set.calledWith("Blocking:#{@doc_id}", "locked", "EX", 30, "NX") + @set.calledWith("lock:web:{#{@doc_id}}", "locked", "EX", 30, "NX") .should.equal true it "should return the callback with true", ->