UNPKG

coffee-core

Version:

Coffee IT API core library

18 lines (14 loc) 650 B
import { Injectable, Optional } from '@nestjs/common'; import { EventPublisher } from './event-publisher.interface'; import { RabbitMQPublisher } from './rabbitmq-publisher'; import { BrokerConfigInterface } from '../subscriber/broker-config.interface'; @Injectable() export class EventPublisherService { protected readonly publisher: EventPublisher; constructor(config: BrokerConfigInterface, @Optional() eventPublisher?: EventPublisher) { this.publisher = eventPublisher ? eventPublisher : new RabbitMQPublisher(config); } public async hasActiveConnection(): Promise<boolean> { return this.publisher.hasActiveConnection(); } }