"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
class EcPublisher {
    /**
     *
     * @param payloadSchema 消息格式
     * @param sendType 01 - 群发：同一个topic如果多个目标环境订阅，这些目标环境都发
     *                 02 - 定向：只发送到客户端所处环境对应的目标环境
     */
    static publish(payloadSchema, sendType) {
        const Pulsar = require('pulsar-client');
        (() => __awaiter(this, void 0, void 0, function* () {
            const client = new Pulsar.Client({
                //todo 定时拉取注册中心作缓存
                serviceUrl: 'pulsar://101.37.145.159:6650',
            });
            const producer = yield client.createProducer({
                topic: 'persistent://yongqiangTenant/yongqiangNamespace/yongqiangTopic',
            });
            // Send messages
            const msg = JSON.stringify(payloadSchema);
            producer.send({
                data: Buffer.from(msg),
            });
        }))();
    }
}
exports.EcPublisher = EcPublisher;
//# sourceMappingURL=producer.js.map