mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-23 05:42:55 +00:00
Use the main redis instance for locks
This commit is contained in:
parent
e912ccc562
commit
508a95c19b
5 changed files with 9 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
metrics = require('./Metrics')
|
||||
Settings = require('settings-sharelatex')
|
||||
rclient = require("./RedisBackend").createClient()
|
||||
keys = require('./RedisKeyBuilder')
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
logger = require "logger-sharelatex"
|
||||
os = require "os"
|
||||
crypto = require "crypto"
|
||||
|
@ -11,6 +11,9 @@ PID = process.pid
|
|||
RND = crypto.randomBytes(4).toString('hex')
|
||||
COUNT = 0
|
||||
|
||||
keys =
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
|
||||
module.exports = LockManager =
|
||||
LOCK_TEST_INTERVAL: 50 # 50ms between each test of the lock
|
||||
MAX_LOCK_WAIT_TIME: 10000 # 10s maximum time to spend trying to get the lock
|
||||
|
|
|
@ -14,9 +14,7 @@ describe 'LockManager - checking the lock', ()->
|
|||
|
||||
mocks =
|
||||
"logger-sharelatex": log:->
|
||||
"./RedisKeyBuilder":
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
"./RedisBackend":
|
||||
"redis-sharelatex":
|
||||
createClient : ()->
|
||||
auth:->
|
||||
exists: existsStub
|
||||
|
|
|
@ -12,9 +12,7 @@ describe 'LockManager - releasing the lock', ()->
|
|||
evalStub = sinon.stub().yields(1)
|
||||
mocks =
|
||||
"logger-sharelatex": log:->
|
||||
"./RedisKeyBuilder":
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
"./RedisBackend":
|
||||
"redis-sharelatex":
|
||||
createClient : ()->
|
||||
auth:->
|
||||
eval: evalStub
|
||||
|
|
|
@ -8,9 +8,7 @@ describe 'LockManager - getting the lock', ->
|
|||
beforeEach ->
|
||||
@LockManager = SandboxedModule.require modulePath, requires:
|
||||
"logger-sharelatex": log:->
|
||||
"./RedisKeyBuilder":
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
"./RedisBackend":
|
||||
"redis-sharelatex":
|
||||
createClient : () =>
|
||||
auth:->
|
||||
"./Metrics": {inc: () ->}
|
||||
|
|
|
@ -8,9 +8,7 @@ describe 'LockManager - trying the lock', ->
|
|||
beforeEach ->
|
||||
@LockManager = SandboxedModule.require modulePath, requires:
|
||||
"logger-sharelatex": log:->
|
||||
"./RedisKeyBuilder":
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
"./RedisBackend":
|
||||
"redis-sharelatex":
|
||||
createClient : () =>
|
||||
auth:->
|
||||
set: @set = sinon.stub()
|
||||
|
|
Loading…
Reference in a new issue