diff --git a/services/document-updater/app.coffee b/services/document-updater/app.coffee index 31e8ebb3b3..eb0ea771aa 100644 --- a/services/document-updater/app.coffee +++ b/services/document-updater/app.coffee @@ -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? diff --git a/services/document-updater/app/coffee/DocumentManager.coffee b/services/document-updater/app/coffee/DocumentManager.coffee index be47ec4c8c..c155de58fe 100644 --- a/services/document-updater/app/coffee/DocumentManager.coffee +++ b/services/document-updater/app/coffee/DocumentManager.coffee @@ -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" diff --git a/services/document-updater/app/coffee/WebRedisManager.coffee b/services/document-updater/app/coffee/RealTimeRedisManager.coffee similarity index 88% rename from services/document-updater/app/coffee/WebRedisManager.coffee rename to services/document-updater/app/coffee/RealTimeRedisManager.coffee index 6b7326d73a..197a4708c1 100644 --- a/services/document-updater/app/coffee/WebRedisManager.coffee +++ b/services/document-updater/app/coffee/RealTimeRedisManager.coffee @@ -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 diff --git a/services/document-updater/app/coffee/ShareJsUpdateManager.coffee b/services/document-updater/app/coffee/ShareJsUpdateManager.coffee index f175796467..3ec90e4f62 100644 --- a/services/document-updater/app/coffee/ShareJsUpdateManager.coffee +++ b/services/document-updater/app/coffee/ShareJsUpdateManager.coffee @@ -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} diff --git a/services/document-updater/app/coffee/UpdateManager.coffee b/services/document-updater/app/coffee/UpdateManager.coffee index b6a5f98c4c..5022f6bb38 100644 --- a/services/document-updater/app/coffee/UpdateManager.coffee +++ b/services/document-updater/app/coffee/UpdateManager.coffee @@ -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 diff --git a/services/document-updater/config/settings.defaults.coffee b/services/document-updater/config/settings.defaults.coffee index 973cfca970..ae5ff0522b 100755 --- a/services/document-updater/config/settings.defaults.coffee +++ b/services/document-updater/config/settings.defaults.coffee @@ -16,7 +16,7 @@ module.exports = url: "http://localhost:3015" redis: - web: + realtime: port:"6379" host:"localhost" password:"" diff --git a/services/document-updater/test/unit/coffee/DocumentManager/DocumentManagerTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/DocumentManagerTests.coffee index 47fbde021b..e781546ec6 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/DocumentManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/DocumentManagerTests.coffee @@ -16,7 +16,7 @@ describe "DocumentManager", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() - "./WebRedisManager": @WebRedisManager = {} + "./RealTimeRedisManager": @RealTimeRedisManager = {} "./DiffCodec": @DiffCodec = {} "./UpdateManager": @UpdateManager = {} "./RangesManager": @RangesManager = {} diff --git a/services/document-updater/test/unit/coffee/WebRedisManager/WebRedisManagerTests.coffee b/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee similarity index 83% rename from services/document-updater/test/unit/coffee/WebRedisManager/WebRedisManagerTests.coffee rename to services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee index e1fb89eaed..b6aa35ac72 100644 --- a/services/document-updater/test/unit/coffee/WebRedisManager/WebRedisManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee @@ -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 diff --git a/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee b/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee index 42ba3f331b..b7364b00a4 100644 --- a/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee @@ -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 diff --git a/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee b/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee index fbf9b21ddc..3e659ee078 100644 --- a/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee @@ -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,