mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Rename web -> realtime for consistency with realtime
This commit is contained in:
parent
c5449ae282
commit
ed493d8ad3
10 changed files with 32 additions and 32 deletions
|
@ -62,7 +62,7 @@ app.get '/status', (req, res)->
|
|||
else
|
||||
res.send('document updater is alive')
|
||||
|
||||
webRedisClient = require("redis-sharelatex").createClient(Settings.redis.web)
|
||||
webRedisClient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
||||
app.get "/health_check/redis", (req, res, next) ->
|
||||
webRedisClient.healthCheck (error) ->
|
||||
if error?
|
||||
|
|
|
@ -4,7 +4,7 @@ DiffCodec = require "./DiffCodec"
|
|||
logger = require "logger-sharelatex"
|
||||
Metrics = require "./Metrics"
|
||||
HistoryManager = require "./HistoryManager"
|
||||
WebRedisManager = require "./WebRedisManager"
|
||||
RealTimeRedisManager = require "./RealTimeRedisManager"
|
||||
Errors = require "./Errors"
|
||||
RangesManager = require "./RangesManager"
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
Settings = require('settings-sharelatex')
|
||||
rclient = require("redis-sharelatex").createClient(Settings.redis.web)
|
||||
Keys = Settings.redis.web.key_schema
|
||||
rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
||||
Keys = Settings.redis.realtime.key_schema
|
||||
logger = require('logger-sharelatex')
|
||||
|
||||
module.exports = WebRedisManager =
|
||||
module.exports = RealTimeRedisManager =
|
||||
getPendingUpdatesForDoc : (doc_id, callback)->
|
||||
multi = rclient.multi()
|
||||
multi.lrange Keys.pendingUpdates({doc_id}), 0 , -1
|
|
@ -6,7 +6,7 @@ Settings = require('settings-sharelatex')
|
|||
Keys = require "./UpdateKeys"
|
||||
{EventEmitter} = require "events"
|
||||
util = require "util"
|
||||
WebRedisManager = require "./WebRedisManager"
|
||||
RealTimeRedisManager = require "./RealTimeRedisManager"
|
||||
|
||||
ShareJsModel:: = {}
|
||||
util.inherits ShareJsModel, EventEmitter
|
||||
|
@ -52,5 +52,5 @@ module.exports = ShareJsUpdateManager =
|
|||
ShareJsUpdateManager._sendOp(project_id, doc_id, opData)
|
||||
|
||||
_sendOp: (project_id, doc_id, op) ->
|
||||
WebRedisManager.sendData {project_id, doc_id, op}
|
||||
RealTimeRedisManager.sendData {project_id, doc_id, op}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
LockManager = require "./LockManager"
|
||||
RedisManager = require "./RedisManager"
|
||||
WebRedisManager = require "./WebRedisManager"
|
||||
RealTimeRedisManager = require "./RealTimeRedisManager"
|
||||
ShareJsUpdateManager = require "./ShareJsUpdateManager"
|
||||
HistoryManager = require "./HistoryManager"
|
||||
Settings = require('settings-sharelatex')
|
||||
|
@ -30,7 +30,7 @@ module.exports = UpdateManager =
|
|||
UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback
|
||||
|
||||
continueProcessingUpdatesWithLock: (project_id, doc_id, callback = (error) ->) ->
|
||||
WebRedisManager.getUpdatesLength doc_id, (error, length) =>
|
||||
RealTimeRedisManager.getUpdatesLength doc_id, (error, length) =>
|
||||
return callback(error) if error?
|
||||
if length > 0
|
||||
UpdateManager.processOutstandingUpdatesWithLock project_id, doc_id, callback
|
||||
|
@ -38,7 +38,7 @@ module.exports = UpdateManager =
|
|||
callback()
|
||||
|
||||
fetchAndApplyUpdates: (project_id, doc_id, callback = (error) ->) ->
|
||||
WebRedisManager.getPendingUpdatesForDoc doc_id, (error, updates) =>
|
||||
RealTimeRedisManager.getPendingUpdatesForDoc doc_id, (error, updates) =>
|
||||
return callback(error) if error?
|
||||
if updates.length == 0
|
||||
return callback()
|
||||
|
@ -49,7 +49,7 @@ module.exports = UpdateManager =
|
|||
applyUpdate: (project_id, doc_id, update, _callback = (error) ->) ->
|
||||
callback = (error) ->
|
||||
if error?
|
||||
WebRedisManager.sendData {project_id, doc_id, error: error.message || error}
|
||||
RealTimeRedisManager.sendData {project_id, doc_id, error: error.message || error}
|
||||
_callback(error)
|
||||
|
||||
UpdateManager._sanitizeUpdate update
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports =
|
|||
url: "http://localhost:3015"
|
||||
|
||||
redis:
|
||||
web:
|
||||
realtime:
|
||||
port:"6379"
|
||||
host:"localhost"
|
||||
password:""
|
||||
|
|
|
@ -16,7 +16,7 @@ describe "DocumentManager", ->
|
|||
"./Metrics": @Metrics =
|
||||
Timer: class Timer
|
||||
done: sinon.stub()
|
||||
"./WebRedisManager": @WebRedisManager = {}
|
||||
"./RealTimeRedisManager": @RealTimeRedisManager = {}
|
||||
"./DiffCodec": @DiffCodec = {}
|
||||
"./UpdateManager": @UpdateManager = {}
|
||||
"./RangesManager": @RangesManager = {}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
sinon = require('sinon')
|
||||
chai = require('chai')
|
||||
should = chai.should()
|
||||
modulePath = "../../../../app/js/WebRedisManager.js"
|
||||
modulePath = "../../../../app/js/RealTimeRedisManager.js"
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
Errors = require "../../../../app/js/Errors"
|
||||
|
||||
describe "WebRedisManager", ->
|
||||
describe "RealTimeRedisManager", ->
|
||||
beforeEach ->
|
||||
@rclient =
|
||||
auth: () ->
|
||||
exec: sinon.stub()
|
||||
@rclient.multi = () => @rclient
|
||||
@WebRedisManager = SandboxedModule.require modulePath, requires:
|
||||
@RealTimeRedisManager = SandboxedModule.require modulePath, requires:
|
||||
"redis-sharelatex": createClient: () => @rclient
|
||||
"settings-sharelatex":
|
||||
redis:
|
||||
web: @settings =
|
||||
realtime: @settings =
|
||||
key_schema:
|
||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||
"logger-sharelatex": { log: () -> }
|
||||
|
@ -36,7 +36,7 @@ describe "WebRedisManager", ->
|
|||
]
|
||||
@jsonUpdates = @updates.map (update) -> JSON.stringify update
|
||||
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates])
|
||||
@WebRedisManager.getPendingUpdatesForDoc @doc_id, @callback
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc @doc_id, @callback
|
||||
|
||||
it "should get the pending updates", ->
|
||||
@rclient.lrange
|
||||
|
@ -58,7 +58,7 @@ describe "WebRedisManager", ->
|
|||
"broken json"
|
||||
]
|
||||
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates])
|
||||
@WebRedisManager.getPendingUpdatesForDoc @doc_id, @callback
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc @doc_id, @callback
|
||||
|
||||
it "should return an error to the callback", ->
|
||||
@callback.calledWith(new Error("JSON parse error")).should.equal true
|
||||
|
@ -67,7 +67,7 @@ describe "WebRedisManager", ->
|
|||
describe "getUpdatesLength", ->
|
||||
beforeEach ->
|
||||
@rclient.llen = sinon.stub().yields(null, @length = 3)
|
||||
@WebRedisManager.getUpdatesLength @doc_id, @callback
|
||||
@RealTimeRedisManager.getUpdatesLength @doc_id, @callback
|
||||
|
||||
it "should look up the length", ->
|
||||
@rclient.llen.calledWith("PendingUpdates:#{@doc_id}").should.equal true
|
|
@ -17,7 +17,7 @@ describe "ShareJsUpdateManager", ->
|
|||
"./ShareJsDB" : @ShareJsDB = { mockDB: true }
|
||||
"redis-sharelatex" : createClient: () => @rclient = auth:->
|
||||
"logger-sharelatex": @logger = { log: sinon.stub() }
|
||||
"./WebRedisManager": @WebRedisManager = {}
|
||||
"./RealTimeRedisManager": @RealTimeRedisManager = {}
|
||||
globals:
|
||||
clearTimeout: @clearTimeout = sinon.stub()
|
||||
|
||||
|
@ -105,11 +105,11 @@ describe "ShareJsUpdateManager", ->
|
|||
@opData =
|
||||
op: {t: "foo", p: 1}
|
||||
meta: source: "bar"
|
||||
@WebRedisManager.sendData = sinon.stub()
|
||||
@RealTimeRedisManager.sendData = sinon.stub()
|
||||
@callback("#{@project_id}:#{@doc_id}", @opData)
|
||||
|
||||
it "should publish the op to redis", ->
|
||||
@WebRedisManager.sendData
|
||||
@RealTimeRedisManager.sendData
|
||||
.calledWith({project_id: @project_id, doc_id: @doc_id, op: @opData})
|
||||
.should.equal true
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ describe "UpdateManager", ->
|
|||
@UpdateManager = SandboxedModule.require modulePath, requires:
|
||||
"./LockManager" : @LockManager = {}
|
||||
"./RedisManager" : @RedisManager = {}
|
||||
"./WebRedisManager" : @WebRedisManager = {}
|
||||
"./RealTimeRedisManager" : @RealTimeRedisManager = {}
|
||||
"./ShareJsUpdateManager" : @ShareJsUpdateManager = {}
|
||||
"./HistoryManager" : @HistoryManager = {}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub() }
|
||||
|
@ -94,7 +94,7 @@ describe "UpdateManager", ->
|
|||
describe "continueProcessingUpdatesWithLock", ->
|
||||
describe "when there are outstanding updates", ->
|
||||
beforeEach ->
|
||||
@WebRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 3)
|
||||
@RealTimeRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 3)
|
||||
@UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2)
|
||||
@UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback
|
||||
|
||||
|
@ -106,7 +106,7 @@ describe "UpdateManager", ->
|
|||
|
||||
describe "when there are no outstanding updates", ->
|
||||
beforeEach ->
|
||||
@WebRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 0)
|
||||
@RealTimeRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 0)
|
||||
@UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2)
|
||||
@UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback
|
||||
|
||||
|
@ -122,12 +122,12 @@ describe "UpdateManager", ->
|
|||
@updates = [{p: 1, t: "foo"}]
|
||||
@updatedDocLines = ["updated", "lines"]
|
||||
@version = 34
|
||||
@WebRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates)
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates)
|
||||
@UpdateManager.applyUpdate = sinon.stub().callsArgWith(3, null, @updatedDocLines, @version)
|
||||
@UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback
|
||||
|
||||
it "should get the pending updates", ->
|
||||
@WebRedisManager.getPendingUpdatesForDoc.calledWith(@doc_id).should.equal true
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc.calledWith(@doc_id).should.equal true
|
||||
|
||||
it "should apply the updates", ->
|
||||
for update in @updates
|
||||
|
@ -141,7 +141,7 @@ describe "UpdateManager", ->
|
|||
describe "when there are no updates", ->
|
||||
beforeEach ->
|
||||
@updates = []
|
||||
@WebRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates)
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates)
|
||||
@UpdateManager.applyUpdate = sinon.stub()
|
||||
@RedisManager.setDocument = sinon.stub()
|
||||
@UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback
|
||||
|
@ -165,7 +165,7 @@ describe "UpdateManager", ->
|
|||
@RangesManager.applyUpdate = sinon.stub().yields(null, @updated_ranges)
|
||||
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps)
|
||||
@RedisManager.updateDocument = sinon.stub().yields()
|
||||
@WebRedisManager.sendData = sinon.stub()
|
||||
@RealTimeRedisManager.sendData = sinon.stub()
|
||||
@HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(3)
|
||||
|
||||
describe "normally", ->
|
||||
|
@ -214,8 +214,8 @@ describe "UpdateManager", ->
|
|||
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(@error)
|
||||
@UpdateManager.applyUpdate @project_id, @doc_id, @update, @callback
|
||||
|
||||
it "should call WebRedisManager.sendData with the error", ->
|
||||
@WebRedisManager.sendData
|
||||
it "should call RealTimeRedisManager.sendData with the error", ->
|
||||
@RealTimeRedisManager.sendData
|
||||
.calledWith({
|
||||
project_id: @project_id,
|
||||
doc_id: @doc_id,
|
||||
|
|
Loading…
Reference in a new issue