mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-23 01:23:59 +00:00
Revert robust redis connection code
This commit is contained in:
parent
8b9a26d6f3
commit
cd8c233c05
6 changed files with 6 additions and 32 deletions
|
@ -1,14 +1,11 @@
|
|||
Settings = require 'settings-sharelatex'
|
||||
redis = require("redis-sharelatex")
|
||||
rclientPub = redis.createClient(Settings.redis.web)
|
||||
rclientSub = redis.createMonitoredSubscriptionClient(Settings.redis.web)
|
||||
rclientSub = redis.createClient(Settings.redis.web)
|
||||
|
||||
module.exports = EditorRealTimeController =
|
||||
rclientPub: rclientPub
|
||||
rclientSub: rclientSub
|
||||
|
||||
isRedisPubSubAlive: () ->
|
||||
rclientSub.isAlive()
|
||||
|
||||
emitToRoom: (room_id, message, payload...) ->
|
||||
@rclientPub.publish "editor-events", JSON.stringify
|
||||
|
@ -21,9 +18,7 @@ module.exports = EditorRealTimeController =
|
|||
|
||||
listenForEditorEvents: () ->
|
||||
@rclientSub.subscribe "editor-events"
|
||||
@rclientSub.on "message", (channel, message) ->
|
||||
return unless channel == "editor-events"
|
||||
EditorRealTimeController._processEditorEvent(channel, message)
|
||||
@rclientSub.on "message", @_processEditorEvent.bind(@)
|
||||
|
||||
_processEditorEvent: (channel, message) ->
|
||||
io = require('../../infrastructure/Server').io
|
||||
|
|
|
@ -2,11 +2,10 @@ logger = require "logger-sharelatex"
|
|||
metrics = require('../../infrastructure/Metrics')
|
||||
Settings = require 'settings-sharelatex'
|
||||
redis = require("redis-sharelatex")
|
||||
rclient = redis.createClient(Settings.redis.web)
|
||||
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
|
||||
EditorRealTimeController = require("./EditorRealTimeController")
|
||||
|
||||
rclient = redis.createMonitoredSubscriptionClient(Settings.redis.web)
|
||||
|
||||
module.exports = EditorUpdatesController =
|
||||
_applyUpdate: (client, project_id, doc_id, update, callback = (error) ->) ->
|
||||
metrics.inc "editor.doc-update", 0.3
|
||||
|
@ -29,14 +28,9 @@ module.exports = EditorUpdatesController =
|
|||
update.meta.user_id = user_id
|
||||
EditorUpdatesController._applyUpdate client, project_id, doc_id, update
|
||||
|
||||
isRedisPubSubAlive: () ->
|
||||
rclient.isAlive()
|
||||
|
||||
listenForUpdatesFromDocumentUpdater: () ->
|
||||
rclient.subscribe "applied-ops"
|
||||
rclient.on "message", (channel, message) ->
|
||||
return unless channel == "applied-ops"
|
||||
EditorUpdatesController._processMessageFromDocumentUpdater(channel, message)
|
||||
rclient.on "message", @_processMessageFromDocumentUpdater.bind(@)
|
||||
|
||||
_processMessageFromDocumentUpdater: (channel, message) ->
|
||||
message = JSON.parse message
|
||||
|
|
|
@ -8,7 +8,6 @@ AuthorizationManager = require('./Features/Security/AuthorizationManager')
|
|||
EditorController = require("./Features/Editor/EditorController")
|
||||
EditorRouter = require("./Features/Editor/EditorRouter")
|
||||
EditorUpdatesController = require("./Features/Editor/EditorUpdatesController")
|
||||
EditorRealTimeController = require("./Features/Editor/EditorRealTimeController")
|
||||
Settings = require('settings-sharelatex')
|
||||
TpdsController = require('./Features/ThirdPartyDataStore/TpdsController')
|
||||
SubscriptionRouter = require './Features/Subscription/SubscriptionRouter'
|
||||
|
@ -176,18 +175,6 @@ module.exports = class Router
|
|||
req.session.destroy()
|
||||
|
||||
app.get '/health_check', HealthCheckController.check
|
||||
|
||||
app.get '/health_check/redis/doc_updates', (req, res, next) ->
|
||||
if EditorUpdatesController.isRedisPubSubAlive()
|
||||
res.send(200)
|
||||
else
|
||||
res.send(500)
|
||||
|
||||
app.get '/health_check/redis/websockets', (req, res, next) ->
|
||||
if EditorRealTimeController.isRedisPubSubAlive()
|
||||
res.send(200)
|
||||
else
|
||||
res.send(500)
|
||||
|
||||
app.get "/status/compiler/:Project_id", SecurityManager.requestCanAccessProject, (req, res) ->
|
||||
sendRes = _.once (statusCode, message)->
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
"optimist": "0.6.1",
|
||||
"redback": "0.4.0",
|
||||
"redis": "0.10.1",
|
||||
"redis-sharelatex": "git+https://github.com/sharelatex/redis-sharelatex.git#master",
|
||||
"redis-sharelatex": "~0.0.4",
|
||||
"request": "2.34.0",
|
||||
"rimraf": "2.2.6",
|
||||
"sanitizer": "0.1.1",
|
||||
|
|
|
@ -9,8 +9,6 @@ describe "EditorRealTimeController", ->
|
|||
"redis-sharelatex":
|
||||
createClient: () ->
|
||||
auth:->
|
||||
createMonitoredSubscriptionClient: () ->
|
||||
auth:->
|
||||
"../../infrastructure/Server" : io: @io = {}
|
||||
@EditorRealTimeController.rclientPub = publish: sinon.stub()
|
||||
@EditorRealTimeController.rclientSub =
|
||||
|
|
|
@ -18,7 +18,7 @@ describe "EditorUpdatesController", ->
|
|||
"../../infrastructure/Metrics" : @metrics = { set: sinon.stub(), inc: sinon.stub() }
|
||||
"../../infrastructure/Server" : io: @io = {}
|
||||
"redis-sharelatex" :
|
||||
createMonitoredSubscriptionClient: ()=>
|
||||
createClient: ()=>
|
||||
@rclient = {auth:->}
|
||||
|
||||
describe "_applyUpdate", ->
|
||||
|
|
Loading…
Reference in a new issue