trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
66 lines (65 loc) • 2.5 kB
TypeScript
import { MessageProperties } from 'amqplib';
import { BaseEntity, Constructor } from '../../entities/core-entities/index.js';
import { IEntityHandler, IFeed, MQSettingsOptions } from '..';
import { ILogger } from '../../logger';
/**
* Class that represent all the abilities of rabbitmq instance
* to consume messages and handle them with all the configured
* desired handlers for entities types and process them with
* the entityHandler call-back function for the entityConstructor
* class type entity type and process them with the entityHandler
* call-back function for the entityConstructor class type entity type
* @implements IFeed interface that represent Feed implementation for
* the feed service to consume messages, process connect creation,
* attach listeners for reconnection and consumption process and
* handle them with all the configured desired handlers for entities
* types
*/
declare class RabbitMQFeed implements IFeed {
private mqSettings;
private logger;
private requestQueue;
private connection;
private channel;
private consumerTag;
private isConnected;
private stopTryReconnect;
private readonly reconnectionLock;
private isReconnecting;
private readonly consumer;
constructor(mqSettings: MQSettingsOptions, logger?: ILogger);
setLogger(logger: ILogger): void;
getLogger(): ILogger;
start(): Promise<void>;
/**
* establish connection to rabbitmq
*/
private connect;
/**
* attach listeners for desire invoked events
*/
private attachListeners;
/**
* handle close event invoke for rabbitmq instance
* handle reconnection option
*/
private connectionClosedHandler;
/**
* handle error event invoke for rabbitmq instance
* connection error
* @param err error been thrown from the connection
* instance of rabbitmq instance connection error
* event invoke handler method call back function
* @returns void
*/
private connectionErrorHandler;
/**
* get the message timestamp from the message properties
* @param msgProperties the message properties
* @returns the message timestamp in milliseconds
*/
getMessageMqTimestamp(msgProperties: MessageProperties): number | undefined;
stop(): Promise<void>;
addEntityHandler<TEntity extends BaseEntity>(entityHandler: IEntityHandler<TEntity>, entityConstructor: Constructor<TEntity>): Promise<void>;
}
export = RabbitMQFeed;