- requestsToMakeGrouped[hashKey].ids.push(poolRequest._id)
- requestsToMakeGrouped[hashKey].datas.push(poolRequest.request)
- })
- })
-
- const goodPods = []
- const badPods = []
-
- eachLimit(Object.keys(requestsToMakeGrouped), constants.REQUESTS_IN_PARALLEL, function (hashKey, callbackEach) {
- const requestToMake = requestsToMakeGrouped[hashKey]
-
- // FIXME: mongodb request inside a loop :/
- Pod.load(requestToMake.toPodId, function (err, toPod) {
- if (err) {
- logger.error('Error finding pod by id.', { err: err })
- return callbackEach()
- }
-
- // Maybe the pod is not our friend anymore so simply remove it
- if (!toPod) {
- const requestIdsToDelete = requestToMake.ids
-
- logger.info('Removing %d requests of unexisting pod %s.', requestIdsToDelete.length, requestToMake.toPodId)
- removePodOf.call(self, requestIdsToDelete, requestToMake.toPodId)
- return callbackEach()
- }
-
- makeRequest(toPod, requestToMake.endpoint, requestToMake.datas, function (success) {
- if (success === true) {
- logger.debug('Removing requests for %s pod.', requestToMake.toPodId, { requestsIds: requestToMake.ids })
-
- goodPods.push(requestToMake.toPodId)