- Pods.list(function (err, pods) {
- if (err) return callback(err)
-
- const params = {
- encrypt: true, // Security
- sign: true, // To prove our identity
- method: 'POST',
- path: null, // We build the path later
- data: requestsToMake // Requests we need to make
- }
-
- // If this is a valid type, we build the path
- if (REQUEST_SCHEDULER_TYPE.indexOf(type) > -1) {
- params.path = '/api/' + constants.API_VERSION + '/remotevideos/' + type
- } else {
- return callback(new Error('Unkown pool request type.'))
- }
-
- const badPods = []
- const goodPods = []
-
- // Make multiple retry requests to all of pods
- // The function fire some useful callbacks
- requests.makeMultipleRetryRequest(params, pods, callbackEachPodFinished, callbackAllPodsFinished)
-
- function callbackEachPodFinished (err, response, body, url, pod, callbackEachPodFinished) {
- // We failed the request, add the pod unreachable to the bad pods list
- if (err || (response.statusCode !== 200 && response.statusCode !== 201 && response.statusCode !== 204)) {
- badPods.push(pod._id)
- logger.error('Error sending secure request to %s pod.', url, { error: err || new Error('Status code not 20x') })
- } else {
- // Request success
- goodPods.push(pod._id)
- }
-
- return callbackEachPodFinished()
+ const params = {
+ toPod: toPod,
+ encrypt: true, // Security
+ sign: true, // To prove our identity
+ method: 'POST',
+ path: '/api/' + constants.API_VERSION + '/remote/videos',
+ data: requestsToMake // Requests we need to make
+ }
+
+ // Make multiple retry requests to all of pods
+ // The function fire some useful callbacks
+ requests.makeSecureRequest(params, function (err, res) {
+ if (err || (res.statusCode !== 200 && res.statusCode !== 201 && res.statusCode !== 204)) {
+ logger.error('Error sending secure request to %s pod.', toPod.url, { error: err || new Error('Status code not 20x') })
+
+ return callback(false)