mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
remove redis.realtime
real time pushes data into the document updater redis instance
This commit is contained in:
parent
9437cf8b02
commit
25e1ad7491
8 changed files with 16 additions and 30 deletions
|
@ -70,15 +70,6 @@ app.get '/status', (req, res)->
|
||||||
else
|
else
|
||||||
res.send('document updater is alive')
|
res.send('document updater is alive')
|
||||||
|
|
||||||
webRedisClient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
|
||||||
app.get "/health_check/redis", (req, res, next) ->
|
|
||||||
webRedisClient.healthCheck (error) ->
|
|
||||||
if error?
|
|
||||||
logger.err {err: error}, "failed redis health check"
|
|
||||||
res.send 500
|
|
||||||
else
|
|
||||||
res.send 200
|
|
||||||
|
|
||||||
docUpdaterRedisClient = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
|
docUpdaterRedisClient = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
|
||||||
app.get "/health_check/redis_cluster", (req, res, next) ->
|
app.get "/health_check/redis_cluster", (req, res, next) ->
|
||||||
docUpdaterRedisClient.healthCheck (error) ->
|
docUpdaterRedisClient.healthCheck (error) ->
|
||||||
|
|
|
@ -10,7 +10,7 @@ RateLimitManager = require('./RateLimitManager')
|
||||||
|
|
||||||
module.exports = DispatchManager =
|
module.exports = DispatchManager =
|
||||||
createDispatcher: (RateLimiter) ->
|
createDispatcher: (RateLimiter) ->
|
||||||
client = redis.createClient(Settings.redis.realtime)
|
client = redis.createClient(Settings.redis.documentupdater)
|
||||||
worker = {
|
worker = {
|
||||||
client: client
|
client: client
|
||||||
_waitForUpdateThenDispatchWorker: (callback = (error) ->) ->
|
_waitForUpdateThenDispatchWorker: (callback = (error) ->) ->
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Settings = require('settings-sharelatex')
|
Settings = require('settings-sharelatex')
|
||||||
rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
rclient = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
|
||||||
Keys = Settings.redis.realtime.key_schema
|
Keys = Settings.redis.documentupdater.key_schema
|
||||||
logger = require('logger-sharelatex')
|
logger = require('logger-sharelatex')
|
||||||
|
|
||||||
MAX_OPS_PER_ITERATION = 8 # process a limited number of ops for safety
|
MAX_OPS_PER_ITERATION = 8 # process a limited number of ops for safety
|
||||||
|
|
|
@ -20,18 +20,6 @@ module.exports =
|
||||||
url: "http://#{process.env["PROJECT_HISTORY_HOST"] or "localhost"}:3054"
|
url: "http://#{process.env["PROJECT_HISTORY_HOST"] or "localhost"}:3054"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
realtime:
|
|
||||||
port: process.env["REAL_TIME_REDIS_PORT"] or process.env["REDIS_PORT"] or "6379"
|
|
||||||
host: process.env["REAL_TIME_REDIS_HOST"] or process.env["REDIS_HOST"] or "localhost"
|
|
||||||
password: process.env["REAL_TIME_REDIS_PASSWORD"] or process.env["REDIS_PASSWORD"] or ""
|
|
||||||
key_schema:
|
|
||||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
|
||||||
# cluster: [{
|
|
||||||
# port: "7000"
|
|
||||||
# host: "localhost"
|
|
||||||
# }]
|
|
||||||
# key_schema:
|
|
||||||
# pendingUpdates: ({doc_id}) -> "PendingUpdates:{#{doc_id}}"
|
|
||||||
documentupdater:
|
documentupdater:
|
||||||
port: process.env["DOC_UPDATER_REDIS_PORT"] or process.env["REDIS_PORT"] or "6379"
|
port: process.env["DOC_UPDATER_REDIS_PORT"] or process.env["REDIS_PORT"] or "6379"
|
||||||
host: process.env["DOC_UPDATER_REDIS_HOST"] or process.env["REDIS_HOST"] or "localhost"
|
host: process.env["DOC_UPDATER_REDIS_HOST"] or process.env["REDIS_HOST"] or "localhost"
|
||||||
|
@ -49,6 +37,7 @@ module.exports =
|
||||||
projectHistoryId: ({doc_id}) -> "ProjectHistoryId:#{doc_id}"
|
projectHistoryId: ({doc_id}) -> "ProjectHistoryId:#{doc_id}"
|
||||||
projectState: ({project_id}) -> "ProjectState:#{project_id}"
|
projectState: ({project_id}) -> "ProjectState:#{project_id}"
|
||||||
unflushedTime: ({doc_id}) -> "UnflushedTime:#{doc_id}"
|
unflushedTime: ({doc_id}) -> "UnflushedTime:#{doc_id}"
|
||||||
|
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||||
# cluster: [{
|
# cluster: [{
|
||||||
# port: "7000"
|
# port: "7000"
|
||||||
# host: "localhost"
|
# host: "localhost"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
Settings = require('settings-sharelatex')
|
Settings = require('settings-sharelatex')
|
||||||
rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
rclient = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
|
||||||
keys = Settings.redis.realtime.key_schema
|
keys = Settings.redis.documentupdater.key_schema
|
||||||
request = require("request").defaults(jar: false)
|
request = require("request").defaults(jar: false)
|
||||||
async = require "async"
|
async = require "async"
|
||||||
|
|
||||||
rclient_sub = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
rclient_sub = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
|
||||||
rclient_sub.subscribe "applied-ops"
|
rclient_sub.subscribe "applied-ops"
|
||||||
rclient_sub.setMaxListeners(0)
|
rclient_sub.setMaxListeners(0)
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,21 @@ should = chai.should()
|
||||||
modulePath = "../../../../app/js/DispatchManager.js"
|
modulePath = "../../../../app/js/DispatchManager.js"
|
||||||
SandboxedModule = require('sandboxed-module')
|
SandboxedModule = require('sandboxed-module')
|
||||||
|
|
||||||
|
|
||||||
describe "DispatchManager", ->
|
describe "DispatchManager", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@timeout(3000)
|
||||||
@DispatchManager = SandboxedModule.require modulePath, requires:
|
@DispatchManager = SandboxedModule.require modulePath, requires:
|
||||||
"./UpdateManager" : @UpdateManager = {}
|
"./UpdateManager" : @UpdateManager = {}
|
||||||
"logger-sharelatex": @logger = { log: sinon.stub() }
|
"logger-sharelatex": @logger = { log: sinon.stub() }
|
||||||
"settings-sharelatex": @settings =
|
"settings-sharelatex": @settings =
|
||||||
redis:
|
redis:
|
||||||
realtime: {}
|
documentupdater: {}
|
||||||
"redis-sharelatex": @redis = {}
|
"redis-sharelatex": @redis = {}
|
||||||
"./RateLimitManager": {}
|
"./RateLimitManager": {}
|
||||||
|
"./Metrics":
|
||||||
|
Timer: ->
|
||||||
|
done: ->
|
||||||
@callback = sinon.stub()
|
@callback = sinon.stub()
|
||||||
@RateLimiter = { run: (task,cb) -> task(cb) } # run task without rate limit
|
@RateLimiter = { run: (task,cb) -> task(cb) } # run task without rate limit
|
||||||
|
|
||||||
|
@ -22,7 +27,6 @@ describe "DispatchManager", ->
|
||||||
@client =
|
@client =
|
||||||
auth: sinon.stub()
|
auth: sinon.stub()
|
||||||
@redis.createClient = sinon.stub().returns @client
|
@redis.createClient = sinon.stub().returns @client
|
||||||
|
|
||||||
@worker = @DispatchManager.createDispatcher(@RateLimiter)
|
@worker = @DispatchManager.createDispatcher(@RateLimiter)
|
||||||
|
|
||||||
it "should create a new redis client", ->
|
it "should create a new redis client", ->
|
||||||
|
|
|
@ -24,6 +24,8 @@ describe "ProjectHistoryRedisManager", ->
|
||||||
}
|
}
|
||||||
"redis-sharelatex":
|
"redis-sharelatex":
|
||||||
createClient: () => @rclient
|
createClient: () => @rclient
|
||||||
|
"logger-sharelatex":
|
||||||
|
log:->
|
||||||
globals:
|
globals:
|
||||||
JSON: @JSON = JSON
|
JSON: @JSON = JSON
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe "RealTimeRedisManager", ->
|
||||||
"redis-sharelatex": createClient: () => @rclient
|
"redis-sharelatex": createClient: () => @rclient
|
||||||
"settings-sharelatex":
|
"settings-sharelatex":
|
||||||
redis:
|
redis:
|
||||||
realtime: @settings =
|
documentupdater: @settings =
|
||||||
key_schema:
|
key_schema:
|
||||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||||
"logger-sharelatex": { log: () -> }
|
"logger-sharelatex": { log: () -> }
|
||||||
|
|
Loading…
Reference in a new issue