diff --git a/services/document-updater/app/coffee/RealTimeRedisManager.coffee b/services/document-updater/app/coffee/RealTimeRedisManager.coffee index 5644fe82a0..e949268f62 100644 --- a/services/document-updater/app/coffee/RealTimeRedisManager.coffee +++ b/services/document-updater/app/coffee/RealTimeRedisManager.coffee @@ -1,5 +1,6 @@ Settings = require('settings-sharelatex') -rclient = require("redis-sharelatex").createClient(Settings.redis.pubsub) +rclient = require("redis-sharelatex").createClient(Settings.redis.documentupdater) +pubsubClient = require("redis-sharelatex").createClient(Settings.redis.pubsub) Keys = Settings.redis.documentupdater.key_schema logger = require('logger-sharelatex') os = require "os" @@ -35,4 +36,4 @@ module.exports = RealTimeRedisManager = # create a unique message id using a counter message_id = "doc:#{HOST}:#{RND}-#{COUNT++}" data?._id = message_id - rclient.publish "applied-ops", JSON.stringify(data) + pubsubClient.publish "applied-ops", JSON.stringify(data) diff --git a/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee b/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee index 2d23e948a2..1d97779bfa 100644 --- a/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/RealTimeRedisManager/RealTimeRedisManagerTests.coffee @@ -11,13 +11,17 @@ describe "RealTimeRedisManager", -> auth: () -> exec: sinon.stub() @rclient.multi = () => @rclient + @pubsubClient = + publish: sinon.stub() @RealTimeRedisManager = SandboxedModule.require modulePath, requires: - "redis-sharelatex": createClient: () => @rclient + "redis-sharelatex": createClient: (config) => if (config.name is 'pubsub') then @pubsubClient else @rclient "settings-sharelatex": redis: documentupdater: @settings = key_schema: pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}" + pubsub: + name: "pubsub" "logger-sharelatex": { log: () -> } "crypto": @crypto = { randomBytes: sinon.stub().withArgs(4).returns(Buffer.from([0x1, 0x2, 0x3, 0x4])) } "os": @os = {hostname: sinon.stub().returns("somehost")} @@ -81,8 +85,7 @@ describe "RealTimeRedisManager", -> describe "sendData", -> beforeEach -> @message_id = "doc:somehost:01020304-0" - @rclient.publish = sinon.stub() @RealTimeRedisManager.sendData({op: "thisop"}) it "should send the op with a message id", -> - @rclient.publish.calledWith("applied-ops", JSON.stringify({op:"thisop",_id:@message_id})).should.equal true \ No newline at end of file + @pubsubClient.publish.calledWith("applied-ops", JSON.stringify({op:"thisop",_id:@message_id})).should.equal true \ No newline at end of file