mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-04 22:37:10 +00:00
Add in separate redis config for the lock and fix a few web -> realtime
This commit is contained in:
parent
5c3661d6d9
commit
4104ca4889
6 changed files with 40 additions and 22 deletions
|
@ -11,10 +11,6 @@ DispatchManager = require('./app/js/DispatchManager')
|
|||
Errors = require "./app/js/Errors"
|
||||
HttpController = require "./app/js/HttpController"
|
||||
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
|
||||
|
||||
Path = require "path"
|
||||
Metrics = require "metrics-sharelatex"
|
||||
Metrics.initialize("doc-updater")
|
||||
|
|
|
@ -8,7 +8,7 @@ Metrics = require('./Metrics')
|
|||
|
||||
module.exports = DispatchManager =
|
||||
createDispatcher: () ->
|
||||
client = redis.createClient(Settings.redis.web)
|
||||
client = redis.createClient(Settings.redis.realtime)
|
||||
worker = {
|
||||
client: client
|
||||
_waitForUpdateThenDispatchWorker: (callback = (error) ->) ->
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
metrics = require('./Metrics')
|
||||
Settings = require('settings-sharelatex')
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
rclient = redis.createClient(Settings.redis.lock)
|
||||
keys = Settings.redis.lock.key_schema
|
||||
logger = require "logger-sharelatex"
|
||||
os = require "os"
|
||||
crypto = require "crypto"
|
||||
|
@ -11,9 +12,6 @@ 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
|
||||
|
|
|
@ -22,6 +22,12 @@ module.exports =
|
|||
password:""
|
||||
key_schema:
|
||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||
# cluster: [{
|
||||
# port: "7000"
|
||||
# host: "localhost"
|
||||
# }]
|
||||
# key_schema:
|
||||
# pendingUpdates: ({doc_id}) -> "PendingUpdates:{#{doc_id}}"
|
||||
documentupdater:
|
||||
port: "6379"
|
||||
host: "localhost"
|
||||
|
@ -35,15 +41,6 @@ module.exports =
|
|||
projectKey: ({doc_id}) -> "ProjectId:#{doc_id}"
|
||||
docsInProject: ({project_id}) -> "DocsIn:#{project_id}"
|
||||
ranges: ({doc_id}) -> "Ranges:#{doc_id}"
|
||||
history:
|
||||
port:"6379"
|
||||
host:"localhost"
|
||||
password:""
|
||||
key_schema:
|
||||
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||
|
||||
|
||||
# cluster: [{
|
||||
# port: "7000"
|
||||
# host: "localhost"
|
||||
|
@ -57,6 +54,32 @@ module.exports =
|
|||
# projectKey: ({doc_id}) -> "ProjectId:{#{doc_id}}"
|
||||
# docsInProject: ({project_id}) -> "DocsIn:{#{project_id}}"
|
||||
# ranges: ({doc_id}) -> "Ranges:{#{doc_id}}"
|
||||
history:
|
||||
port:"6379"
|
||||
host:"localhost"
|
||||
password:""
|
||||
key_schema:
|
||||
uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:#{doc_id}"
|
||||
docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:#{project_id}"
|
||||
# cluster: [{
|
||||
# port: "7000"
|
||||
# host: "localhost"
|
||||
# }]
|
||||
# key_schema:
|
||||
# uncompressedHistoryOps: ({doc_id}) -> "UncompressedHistoryOps:{#{doc_id}}"
|
||||
# docsWithHistoryOps: ({project_id}) -> "DocsWithHistoryOps:{#{project_id}}"
|
||||
lock:
|
||||
port:"6379"
|
||||
host:"localhost"
|
||||
password:""
|
||||
key_schema:
|
||||
blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
|
||||
# cluster: [{
|
||||
# port: "7000"
|
||||
# host: "localhost"
|
||||
# }]
|
||||
# key_schema:
|
||||
# blockingKey: ({doc_id}) -> "Blocking:{#{doc_id}}"
|
||||
|
||||
max_doc_length: 2 * 1024 * 1024 # 2mb
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
Settings = require('settings-sharelatex')
|
||||
rclient = require("redis-sharelatex").createClient(Settings.redis.web)
|
||||
rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
||||
keys = Settings.redis.realtime.key_schema
|
||||
request = require("request").defaults(jar: false)
|
||||
async = require "async"
|
||||
|
||||
rclient_sub = require("redis-sharelatex").createClient(Settings.redis.web)
|
||||
rclient_sub = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
||||
rclient_sub.subscribe "applied-ops"
|
||||
rclient_sub.setMaxListeners(0)
|
||||
|
||||
|
@ -17,7 +18,7 @@ module.exports = DocUpdaterClient =
|
|||
rclient_sub.on "message", callback
|
||||
|
||||
sendUpdate: (project_id, doc_id, update, callback = (error) ->) ->
|
||||
rclient.rpush "PendingUpdates:#{doc_id}", JSON.stringify(update), (error)->
|
||||
rclient.rpush keys.pendingUpdates({doc_id}), JSON.stringify(update), (error)->
|
||||
return callback(error) if error?
|
||||
doc_key = "#{project_id}:#{doc_id}"
|
||||
rclient.sadd "DocsWithPendingUpdates", doc_key, (error) ->
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "DispatchManager", ->
|
|||
"logger-sharelatex": @logger = { log: sinon.stub() }
|
||||
"settings-sharelatex": @settings =
|
||||
redis:
|
||||
web: {}
|
||||
realtime: {}
|
||||
"redis-sharelatex": @redis = {}
|
||||
@callback = sinon.stub()
|
||||
|
||||
|
|
Loading…
Reference in a new issue