mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #38 from sharelatex/ja-redis-cluster
Migrate lock to be redis-cluster compatible
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Settings = require "settings-sharelatex"
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
rclient = redis.createClient(Settings.redis.lock)
|
||||
os = require "os"
|
||||
crypto = require "crypto"
|
||||
logger = require "logger-sharelatex"
|
||||
|
||||
@@ -6,6 +6,8 @@ LockManager = require "./LockManager"
|
||||
MongoAWS = require "./MongoAWS"
|
||||
Metrics = require "metrics-sharelatex"
|
||||
ProjectIterator = require "./ProjectIterator"
|
||||
Settings = require "settings-sharelatex"
|
||||
keys = Settings.redis.lock.key_schema
|
||||
|
||||
# Sharejs operations are stored in a 'pack' object
|
||||
#
|
||||
@@ -319,7 +321,7 @@ module.exports = PackManager =
|
||||
|
||||
insertPacksIntoIndexWithLock: (project_id, doc_id, newPacks, callback) ->
|
||||
LockManager.runWithLock(
|
||||
"HistoryIndexLock:#{doc_id}",
|
||||
keys.historyIndexLock({doc_id}),
|
||||
(releaseLock) ->
|
||||
PackManager._insertPacksIntoIndex project_id, doc_id, newPacks, releaseLock
|
||||
callback
|
||||
@@ -438,7 +440,7 @@ module.exports = PackManager =
|
||||
|
||||
markPackAsFinalisedWithLock: (project_id, doc_id, pack_id, callback) ->
|
||||
LockManager.runWithLock(
|
||||
"HistoryLock:#{doc_id}",
|
||||
keys.historyLock({doc_id}),
|
||||
(releaseLock) ->
|
||||
PackManager._markPackAsFinalised project_id, doc_id, pack_id, releaseLock
|
||||
callback
|
||||
|
||||
@@ -9,6 +9,7 @@ logger = require "logger-sharelatex"
|
||||
async = require "async"
|
||||
_ = require "underscore"
|
||||
Settings = require "settings-sharelatex"
|
||||
keys = Settings.redis.lock.key_schema
|
||||
|
||||
module.exports = UpdatesManager =
|
||||
compressAndSaveRawUpdates: (project_id, doc_id, rawUpdates, temporary, callback = (error) ->) ->
|
||||
@@ -126,7 +127,7 @@ module.exports = UpdatesManager =
|
||||
UpdatesManager._prepareDocForUpdates project_id, doc_id, (error) ->
|
||||
return callback(error) if error?
|
||||
LockManager.runWithLock(
|
||||
"HistoryLock:#{doc_id}",
|
||||
keys.historyLock({doc_id}),
|
||||
(releaseLock) ->
|
||||
UpdatesManager.processUncompressedUpdates project_id, doc_id, temporary, releaseLock
|
||||
callback
|
||||
|
||||
Reference in New Issue
Block a user