limit parallel resync doc requests to web

This commit is contained in:
Brian Gough 2018-08-16 11:13:11 +01:00
parent e471730efb
commit aa013f0bee

View file

@ -65,10 +65,12 @@ module.exports = HistoryManager =
newBlock = Math.floor(length / threshold) newBlock = Math.floor(length / threshold)
return newBlock != prevBlock return newBlock != prevBlock
MAX_PARALLEL_REQUESTS: 4
resyncProjectHistory: (project_id, projectHistoryId, docs, files, callback) -> resyncProjectHistory: (project_id, projectHistoryId, docs, files, callback) ->
ProjectHistoryRedisManager.queueResyncProjectStructure project_id, projectHistoryId, docs, files, (error) -> ProjectHistoryRedisManager.queueResyncProjectStructure project_id, projectHistoryId, docs, files, (error) ->
return callback(error) if error? return callback(error) if error?
DocumentManager = require "./DocumentManager" DocumentManager = require "./DocumentManager"
resyncDoc = (doc, cb) -> resyncDoc = (doc, cb) ->
DocumentManager.resyncDocContentsWithLock project_id, doc.doc, cb DocumentManager.resyncDocContentsWithLock project_id, doc.doc, cb
async.each docs, resyncDoc, callback async.eachLimit docs, HistoryManager.MAX_PARALLEL_REQUESTS, resyncDoc, callback