mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Remove multi call to make compatible with redis-cluster
This commit is contained in:
parent
01d0b63f2c
commit
a8917b933f
3 changed files with 7 additions and 27 deletions
|
@ -55,10 +55,8 @@ module.exports = DocumentUpdaterManager =
|
|||
queueChange: (project_id, doc_id, change, callback = ()->)->
|
||||
jsonChange = JSON.stringify change
|
||||
doc_key = "#{project_id}:#{doc_id}"
|
||||
multi = rclient.multi()
|
||||
multi.rpush Keys.pendingUpdates({doc_id}), jsonChange
|
||||
multi.sadd "DocsWithPendingUpdates", doc_key
|
||||
multi.rpush "pending-updates-list", doc_key
|
||||
multi.exec (error) ->
|
||||
# Push onto pendingUpdates for doc_id first, because once the doc updater
|
||||
# gets an entry on pending-updates-list, it starts processing.
|
||||
rclient.rpush Keys.pendingUpdates({doc_id}), jsonChange, (error) ->
|
||||
return callback(error) if error?
|
||||
callback()
|
||||
rclient.rpush "pending-updates-list", doc_key, callback
|
||||
|
|
|
@ -47,11 +47,6 @@ describe "applyOtUpdate", ->
|
|||
doc_id.should.equal "#{@project_id}:#{@doc_id}"
|
||||
done()
|
||||
|
||||
it "should add the doc to the pending updates set in redis", (done) ->
|
||||
rclient.sismember "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", (error, isMember) =>
|
||||
isMember.should.equal 1
|
||||
done()
|
||||
|
||||
it "should push the update into redis", (done) ->
|
||||
rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) =>
|
||||
update = JSON.parse(update)
|
||||
|
@ -146,11 +141,6 @@ describe "applyOtUpdate", ->
|
|||
doc_id.should.equal "#{@project_id}:#{@doc_id}"
|
||||
done()
|
||||
|
||||
it "should add the doc to the pending updates set in redis", (done) ->
|
||||
rclient.sismember "DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}", (error, isMember) =>
|
||||
isMember.should.equal 1
|
||||
done()
|
||||
|
||||
it "should push the update into redis", (done) ->
|
||||
rclient.lrange "PendingUpdates:#{@doc_id}", 0, -1, (error, [update]) =>
|
||||
update = JSON.parse(update)
|
||||
|
|
|
@ -123,10 +123,7 @@ describe 'DocumentUpdaterManager', ->
|
|||
"range":{"start":{"row":2,"column":2},"end":{"row":2,"column":3}},
|
||||
"text":"e"
|
||||
}
|
||||
@rclient.multi = sinon.stub().returns @rclient
|
||||
@rclient.exec = sinon.stub().callsArg(0)
|
||||
@rclient.rpush = sinon.stub()
|
||||
@rclient.sadd = sinon.stub()
|
||||
@rclient.rpush = sinon.stub().yields()
|
||||
@callback = sinon.stub()
|
||||
|
||||
describe "successfully", ->
|
||||
|
@ -143,14 +140,9 @@ describe 'DocumentUpdaterManager', ->
|
|||
.calledWith("pending-updates-list", "#{@project_id}:#{@doc_id}")
|
||||
.should.equal true
|
||||
|
||||
it "should push the doc id into the pending updates set", ->
|
||||
@rclient.sadd
|
||||
.calledWith("DocsWithPendingUpdates", "#{@project_id}:#{@doc_id}")
|
||||
.should.equal true
|
||||
|
||||
describe "with error connecting to redis during exec", ->
|
||||
describe "with error talking to redis during rpush", ->
|
||||
beforeEach ->
|
||||
@rclient.exec = sinon.stub().callsArgWith(0, new Error("something went wrong"))
|
||||
@rclient.rpush = sinon.stub().yields(new Error("something went wrong"))
|
||||
@DocumentUpdaterManager.queueChange(@project_id, @doc_id, @change, @callback)
|
||||
|
||||
it "should return an error", ->
|
||||
|
|
Loading…
Reference in a new issue