mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 15:11:30 -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')
|
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
|
Keys = Settings.redis.documentupdater.key_schema
|
||||||
logger = require('logger-sharelatex')
|
logger = require('logger-sharelatex')
|
||||||
os = require "os"
|
os = require "os"
|
||||||
|
@ -35,4 +36,4 @@ module.exports = RealTimeRedisManager =
|
||||||
# create a unique message id using a counter
|
# create a unique message id using a counter
|
||||||
message_id = "doc:#{HOST}:#{RND}-#{COUNT++}"
|
message_id = "doc:#{HOST}:#{RND}-#{COUNT++}"
|
||||||
data?._id = message_id
|
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: () ->
|
auth: () ->
|
||||||
exec: sinon.stub()
|
exec: sinon.stub()
|
||||||
@rclient.multi = () => @rclient
|
@rclient.multi = () => @rclient
|
||||||
|
@pubsubClient =
|
||||||
|
publish: sinon.stub()
|
||||||
@RealTimeRedisManager = SandboxedModule.require modulePath, requires:
|
@RealTimeRedisManager = SandboxedModule.require modulePath, requires:
|
||||||
"redis-sharelatex": createClient: () => @rclient
|
"redis-sharelatex": createClient: (config) => if (config.name is 'pubsub') then @pubsubClient else @rclient
|
||||||
"settings-sharelatex":
|
"settings-sharelatex":
|
||||||
redis:
|
redis:
|
||||||
documentupdater: @settings =
|
documentupdater: @settings =
|
||||||
key_schema:
|
key_schema:
|
||||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||||
|
pubsub:
|
||||||
|
name: "pubsub"
|
||||||
"logger-sharelatex": { log: () -> }
|
"logger-sharelatex": { log: () -> }
|
||||||
"crypto": @crypto = { randomBytes: sinon.stub().withArgs(4).returns(Buffer.from([0x1, 0x2, 0x3, 0x4])) }
|
"crypto": @crypto = { randomBytes: sinon.stub().withArgs(4).returns(Buffer.from([0x1, 0x2, 0x3, 0x4])) }
|
||||||
"os": @os = {hostname: sinon.stub().returns("somehost")}
|
"os": @os = {hostname: sinon.stub().returns("somehost")}
|
||||||
|
@ -81,8 +85,7 @@ describe "RealTimeRedisManager", ->
|
||||||
describe "sendData", ->
|
describe "sendData", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@message_id = "doc:somehost:01020304-0"
|
@message_id = "doc:somehost:01020304-0"
|
||||||
@rclient.publish = sinon.stub()
|
|
||||||
@RealTimeRedisManager.sendData({op: "thisop"})
|
@RealTimeRedisManager.sendData({op: "thisop"})
|
||||||
|
|
||||||
it "should send the op with a message id", ->
|
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