Rename web -> realtime for consistency with realtime

This commit is contained in:
James Allen 2017-05-02 15:38:33 +01:00
parent c5449ae282
commit ed493d8ad3
10 changed files with 32 additions and 32 deletions

View file

@ -62,7 +62,7 @@ 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.web) webRedisClient = require("redis-sharelatex").createClient(Settings.redis.realtime)
app.get "/health_check/redis", (req, res, next) -> app.get "/health_check/redis", (req, res, next) ->
webRedisClient.healthCheck (error) -> webRedisClient.healthCheck (error) ->
if error? if error?

View file

@ -4,7 +4,7 @@ DiffCodec = require "./DiffCodec"
logger = require "logger-sharelatex" logger = require "logger-sharelatex"
Metrics = require "./Metrics" Metrics = require "./Metrics"
HistoryManager = require "./HistoryManager" HistoryManager = require "./HistoryManager"
WebRedisManager = require "./WebRedisManager" RealTimeRedisManager = require "./RealTimeRedisManager"
Errors = require "./Errors" Errors = require "./Errors"
RangesManager = require "./RangesManager" RangesManager = require "./RangesManager"

View file

@ -1,9 +1,9 @@
Settings = require('settings-sharelatex') Settings = require('settings-sharelatex')
rclient = require("redis-sharelatex").createClient(Settings.redis.web) rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
Keys = Settings.redis.web.key_schema Keys = Settings.redis.realtime.key_schema
logger = require('logger-sharelatex') logger = require('logger-sharelatex')
module.exports = WebRedisManager = module.exports = RealTimeRedisManager =
getPendingUpdatesForDoc : (doc_id, callback)-> getPendingUpdatesForDoc : (doc_id, callback)->
multi = rclient.multi() multi = rclient.multi()
multi.lrange Keys.pendingUpdates({doc_id}), 0 , -1 multi.lrange Keys.pendingUpdates({doc_id}), 0 , -1

View file

@ -6,7 +6,7 @@ Settings = require('settings-sharelatex')
Keys = require "./UpdateKeys" Keys = require "./UpdateKeys"
{EventEmitter} = require "events" {EventEmitter} = require "events"
util = require "util" util = require "util"
WebRedisManager = require "./WebRedisManager" RealTimeRedisManager = require "./RealTimeRedisManager"
ShareJsModel:: = {} ShareJsModel:: = {}
util.inherits ShareJsModel, EventEmitter util.inherits ShareJsModel, EventEmitter
@ -52,5 +52,5 @@ module.exports = ShareJsUpdateManager =
ShareJsUpdateManager._sendOp(project_id, doc_id, opData) ShareJsUpdateManager._sendOp(project_id, doc_id, opData)
_sendOp: (project_id, doc_id, op) -> _sendOp: (project_id, doc_id, op) ->
WebRedisManager.sendData {project_id, doc_id, op} RealTimeRedisManager.sendData {project_id, doc_id, op}

View file

@ -1,6 +1,6 @@
LockManager = require "./LockManager" LockManager = require "./LockManager"
RedisManager = require "./RedisManager" RedisManager = require "./RedisManager"
WebRedisManager = require "./WebRedisManager" RealTimeRedisManager = require "./RealTimeRedisManager"
ShareJsUpdateManager = require "./ShareJsUpdateManager" ShareJsUpdateManager = require "./ShareJsUpdateManager"
HistoryManager = require "./HistoryManager" HistoryManager = require "./HistoryManager"
Settings = require('settings-sharelatex') Settings = require('settings-sharelatex')
@ -30,7 +30,7 @@ module.exports = UpdateManager =
UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback UpdateManager.continueProcessingUpdatesWithLock project_id, doc_id, callback
continueProcessingUpdatesWithLock: (project_id, doc_id, callback = (error) ->) -> continueProcessingUpdatesWithLock: (project_id, doc_id, callback = (error) ->) ->
WebRedisManager.getUpdatesLength doc_id, (error, length) => RealTimeRedisManager.getUpdatesLength doc_id, (error, length) =>
return callback(error) if error? return callback(error) if error?
if length > 0 if length > 0
UpdateManager.processOutstandingUpdatesWithLock project_id, doc_id, callback UpdateManager.processOutstandingUpdatesWithLock project_id, doc_id, callback
@ -38,7 +38,7 @@ module.exports = UpdateManager =
callback() callback()
fetchAndApplyUpdates: (project_id, doc_id, callback = (error) ->) -> fetchAndApplyUpdates: (project_id, doc_id, callback = (error) ->) ->
WebRedisManager.getPendingUpdatesForDoc doc_id, (error, updates) => RealTimeRedisManager.getPendingUpdatesForDoc doc_id, (error, updates) =>
return callback(error) if error? return callback(error) if error?
if updates.length == 0 if updates.length == 0
return callback() return callback()
@ -49,7 +49,7 @@ module.exports = UpdateManager =
applyUpdate: (project_id, doc_id, update, _callback = (error) ->) -> applyUpdate: (project_id, doc_id, update, _callback = (error) ->) ->
callback = (error) -> callback = (error) ->
if 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) _callback(error)
UpdateManager._sanitizeUpdate update UpdateManager._sanitizeUpdate update

View file

@ -16,7 +16,7 @@ module.exports =
url: "http://localhost:3015" url: "http://localhost:3015"
redis: redis:
web: realtime:
port:"6379" port:"6379"
host:"localhost" host:"localhost"
password:"" password:""

View file

@ -16,7 +16,7 @@ describe "DocumentManager", ->
"./Metrics": @Metrics = "./Metrics": @Metrics =
Timer: class Timer Timer: class Timer
done: sinon.stub() done: sinon.stub()
"./WebRedisManager": @WebRedisManager = {} "./RealTimeRedisManager": @RealTimeRedisManager = {}
"./DiffCodec": @DiffCodec = {} "./DiffCodec": @DiffCodec = {}
"./UpdateManager": @UpdateManager = {} "./UpdateManager": @UpdateManager = {}
"./RangesManager": @RangesManager = {} "./RangesManager": @RangesManager = {}

View file

@ -1,21 +1,21 @@
sinon = require('sinon') sinon = require('sinon')
chai = require('chai') chai = require('chai')
should = chai.should() should = chai.should()
modulePath = "../../../../app/js/WebRedisManager.js" modulePath = "../../../../app/js/RealTimeRedisManager.js"
SandboxedModule = require('sandboxed-module') SandboxedModule = require('sandboxed-module')
Errors = require "../../../../app/js/Errors" Errors = require "../../../../app/js/Errors"
describe "WebRedisManager", -> describe "RealTimeRedisManager", ->
beforeEach -> beforeEach ->
@rclient = @rclient =
auth: () -> auth: () ->
exec: sinon.stub() exec: sinon.stub()
@rclient.multi = () => @rclient @rclient.multi = () => @rclient
@WebRedisManager = SandboxedModule.require modulePath, requires: @RealTimeRedisManager = SandboxedModule.require modulePath, requires:
"redis-sharelatex": createClient: () => @rclient "redis-sharelatex": createClient: () => @rclient
"settings-sharelatex": "settings-sharelatex":
redis: redis:
web: @settings = realtime: @settings =
key_schema: key_schema:
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}" pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
"logger-sharelatex": { log: () -> } "logger-sharelatex": { log: () -> }
@ -36,7 +36,7 @@ describe "WebRedisManager", ->
] ]
@jsonUpdates = @updates.map (update) -> JSON.stringify update @jsonUpdates = @updates.map (update) -> JSON.stringify update
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates]) @rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates])
@WebRedisManager.getPendingUpdatesForDoc @doc_id, @callback @RealTimeRedisManager.getPendingUpdatesForDoc @doc_id, @callback
it "should get the pending updates", -> it "should get the pending updates", ->
@rclient.lrange @rclient.lrange
@ -58,7 +58,7 @@ describe "WebRedisManager", ->
"broken json" "broken json"
] ]
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates]) @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", -> it "should return an error to the callback", ->
@callback.calledWith(new Error("JSON parse error")).should.equal true @callback.calledWith(new Error("JSON parse error")).should.equal true
@ -67,7 +67,7 @@ describe "WebRedisManager", ->
describe "getUpdatesLength", -> describe "getUpdatesLength", ->
beforeEach -> beforeEach ->
@rclient.llen = sinon.stub().yields(null, @length = 3) @rclient.llen = sinon.stub().yields(null, @length = 3)
@WebRedisManager.getUpdatesLength @doc_id, @callback @RealTimeRedisManager.getUpdatesLength @doc_id, @callback
it "should look up the length", -> it "should look up the length", ->
@rclient.llen.calledWith("PendingUpdates:#{@doc_id}").should.equal true @rclient.llen.calledWith("PendingUpdates:#{@doc_id}").should.equal true

View file

@ -17,7 +17,7 @@ describe "ShareJsUpdateManager", ->
"./ShareJsDB" : @ShareJsDB = { mockDB: true } "./ShareJsDB" : @ShareJsDB = { mockDB: true }
"redis-sharelatex" : createClient: () => @rclient = auth:-> "redis-sharelatex" : createClient: () => @rclient = auth:->
"logger-sharelatex": @logger = { log: sinon.stub() } "logger-sharelatex": @logger = { log: sinon.stub() }
"./WebRedisManager": @WebRedisManager = {} "./RealTimeRedisManager": @RealTimeRedisManager = {}
globals: globals:
clearTimeout: @clearTimeout = sinon.stub() clearTimeout: @clearTimeout = sinon.stub()
@ -105,11 +105,11 @@ describe "ShareJsUpdateManager", ->
@opData = @opData =
op: {t: "foo", p: 1} op: {t: "foo", p: 1}
meta: source: "bar" meta: source: "bar"
@WebRedisManager.sendData = sinon.stub() @RealTimeRedisManager.sendData = sinon.stub()
@callback("#{@project_id}:#{@doc_id}", @opData) @callback("#{@project_id}:#{@doc_id}", @opData)
it "should publish the op to redis", -> it "should publish the op to redis", ->
@WebRedisManager.sendData @RealTimeRedisManager.sendData
.calledWith({project_id: @project_id, doc_id: @doc_id, op: @opData}) .calledWith({project_id: @project_id, doc_id: @doc_id, op: @opData})
.should.equal true .should.equal true

View file

@ -12,7 +12,7 @@ describe "UpdateManager", ->
@UpdateManager = SandboxedModule.require modulePath, requires: @UpdateManager = SandboxedModule.require modulePath, requires:
"./LockManager" : @LockManager = {} "./LockManager" : @LockManager = {}
"./RedisManager" : @RedisManager = {} "./RedisManager" : @RedisManager = {}
"./WebRedisManager" : @WebRedisManager = {} "./RealTimeRedisManager" : @RealTimeRedisManager = {}
"./ShareJsUpdateManager" : @ShareJsUpdateManager = {} "./ShareJsUpdateManager" : @ShareJsUpdateManager = {}
"./HistoryManager" : @HistoryManager = {} "./HistoryManager" : @HistoryManager = {}
"logger-sharelatex": @logger = { log: sinon.stub() } "logger-sharelatex": @logger = { log: sinon.stub() }
@ -94,7 +94,7 @@ describe "UpdateManager", ->
describe "continueProcessingUpdatesWithLock", -> describe "continueProcessingUpdatesWithLock", ->
describe "when there are outstanding updates", -> describe "when there are outstanding updates", ->
beforeEach -> beforeEach ->
@WebRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 3) @RealTimeRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 3)
@UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2) @UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2)
@UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback @UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback
@ -106,7 +106,7 @@ describe "UpdateManager", ->
describe "when there are no outstanding updates", -> describe "when there are no outstanding updates", ->
beforeEach -> beforeEach ->
@WebRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 0) @RealTimeRedisManager.getUpdatesLength = sinon.stub().callsArgWith(1, null, 0)
@UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2) @UpdateManager.processOutstandingUpdatesWithLock = sinon.stub().callsArg(2)
@UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback @UpdateManager.continueProcessingUpdatesWithLock @project_id, @doc_id, @callback
@ -122,12 +122,12 @@ describe "UpdateManager", ->
@updates = [{p: 1, t: "foo"}] @updates = [{p: 1, t: "foo"}]
@updatedDocLines = ["updated", "lines"] @updatedDocLines = ["updated", "lines"]
@version = 34 @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.applyUpdate = sinon.stub().callsArgWith(3, null, @updatedDocLines, @version)
@UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback @UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback
it "should get the pending updates", -> 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", -> it "should apply the updates", ->
for update in @updates for update in @updates
@ -141,7 +141,7 @@ describe "UpdateManager", ->
describe "when there are no updates", -> describe "when there are no updates", ->
beforeEach -> beforeEach ->
@updates = [] @updates = []
@WebRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates) @RealTimeRedisManager.getPendingUpdatesForDoc = sinon.stub().callsArgWith(1, null, @updates)
@UpdateManager.applyUpdate = sinon.stub() @UpdateManager.applyUpdate = sinon.stub()
@RedisManager.setDocument = sinon.stub() @RedisManager.setDocument = sinon.stub()
@UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback @UpdateManager.fetchAndApplyUpdates @project_id, @doc_id, @callback
@ -165,7 +165,7 @@ describe "UpdateManager", ->
@RangesManager.applyUpdate = sinon.stub().yields(null, @updated_ranges) @RangesManager.applyUpdate = sinon.stub().yields(null, @updated_ranges)
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps) @ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps)
@RedisManager.updateDocument = sinon.stub().yields() @RedisManager.updateDocument = sinon.stub().yields()
@WebRedisManager.sendData = sinon.stub() @RealTimeRedisManager.sendData = sinon.stub()
@HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(3) @HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(3)
describe "normally", -> describe "normally", ->
@ -214,8 +214,8 @@ describe "UpdateManager", ->
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(@error) @ShareJsUpdateManager.applyUpdate = sinon.stub().yields(@error)
@UpdateManager.applyUpdate @project_id, @doc_id, @update, @callback @UpdateManager.applyUpdate @project_id, @doc_id, @update, @callback
it "should call WebRedisManager.sendData with the error", -> it "should call RealTimeRedisManager.sendData with the error", ->
@WebRedisManager.sendData @RealTimeRedisManager.sendData
.calledWith({ .calledWith({
project_id: @project_id, project_id: @project_id,
doc_id: @doc_id, doc_id: @doc_id,