UNPKG

@nestjstools/messaging

Version:

Simplifies asynchronous and synchronous message handling with support for buses, handlers, channels, and consumers. Build scalable, decoupled applications with ease and reliability.

31 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChannelRegistry = void 0; const messaging_exception_1 = require("../exception/messaging.exception"); class ChannelRegistry { constructor(channels, logger) { this.logger = logger; this.registry = new Map(); channels.forEach((channel) => { this.register(channel); this.logger.log(`Channel [${channel.config.name}] was registered`); }); } register(channel) { if (this.registry.has(channel.config.name)) { return; } this.registry.set(channel.config.name, channel); } getByName(name) { if (!this.registry.has(name)) { throw new messaging_exception_1.MessagingException(`There is no channel with name: ${name}`); } return this.registry.get(name); } getAll() { return Array.from(this.registry.values()); } } exports.ChannelRegistry = ChannelRegistry; //# sourceMappingURL=channel.registry.js.map