"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.httpBroadcast = void 0;
const tslib_1 = require("tslib");
const bluebird_1 = require("bluebird");
const logger_1 = require("../../../helpers/logger");
const requests_1 = require("../../../helpers/requests");
const constants_1 = require("../../../initializers/constants");
function httpBroadcast(payload) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const { uris, requestOptions } = payload;
        const badUrls = [];
        const goodUrls = [];
        yield (0, bluebird_1.map)(uris, (uri) => tslib_1.__awaiter(this, void 0, void 0, function* () {
            try {
                yield (0, requests_1.doRequest)(uri, requestOptions);
                goodUrls.push(uri);
            }
            catch (err) {
                logger_1.logger.debug('HTTP broadcast to %s failed.', uri, { err });
                badUrls.push(uri);
            }
        }), { concurrency: constants_1.BROADCAST_CONCURRENCY });
        return { goodUrls, badUrls };
    });
}
exports.httpBroadcast = httpBroadcast;
module.exports = httpBroadcast;
//# sourceMappingURL=http-broadcast.js.map