mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
fix cluster/sentinel connection with real-time
This commit is contained in:
parent
06ad0f7acd
commit
97487a077e
2 changed files with 9 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
@pubsubClient.publish.calledWith("applied-ops", JSON.stringify({op:"thisop",_id:@message_id})).should.equal true
|
Loading…
Reference in a new issue