UNPKG

rapid-mq

Version:

A simple and fast RabbitMQ client for Node.js

1 lines 28.5 kB
{"version":3,"sources":["../src/rapid-connector.ts","../src/rapic-encoder.ts","../src/messager.ts","../src/pubsub-messager.ts","../src/rpc-messager.ts","../src/direct-messager.ts"],"sourcesContent":["/**\r\n * RapidConnector - Handles connection management to RabbitMQ for the rapid-mq package.\r\n * Provides methods to connect, disconnect, and access the underlying connection.\r\n */\r\n\r\nimport * as amqp from 'amqplib';\r\nimport { DefaultRapidEncoder, RapidEncoder } from './rapic-encoder';\r\n\r\n/**\r\n * Options for creating a RapidConnector instance.\r\n */\r\nexport interface RapidConnectorOptions {\r\n /** The RabbitMQ connection URL (e.g., amqp://user:pass@host:port/vhost) */\r\n url: string;\r\n /** Unique application identifier for this connector */\r\n appId: string;\r\n /** Optional encoder for message serialization */\r\n encoder?: RapidEncoder;\r\n}\r\n\r\n/**\r\n * RapidConnector provides a simple interface to manage a RabbitMQ connection.\r\n */\r\nexport class RapidConnector {\r\n private _url: string;\r\n private _appId: string;\r\n private _connection: amqp.ChannelModel | null = null;\r\n private _isConnected: boolean = false;\r\n private _encoder: RapidEncoder;\r\n\r\n /**\r\n * Constructs a new RapidConnector.\r\n * @param options - Configuration options for the connector.\r\n * @throws {Error} If url or appId is not provided.\r\n */\r\n constructor(private options: RapidConnectorOptions) {\r\n if (!options.url) {\r\n throw new Error(\"URL is required\");\r\n }\r\n\r\n if (!options.appId) {\r\n throw new Error(\"App ID is required\");\r\n }\r\n\r\n this._url = options.url;\r\n this._appId = options.appId;\r\n this._encoder = options.encoder || new DefaultRapidEncoder();\r\n }\r\n\r\n /**\r\n * Establishes a connection to RabbitMQ.\r\n * If already connected, this method does nothing.\r\n * @throws {Error} If the connection fails.\r\n */\r\n async connect(): Promise<void> {\r\n if (this._isConnected) {\r\n return;\r\n }\r\n\r\n try {\r\n this._connection = await amqp.connect(this._url);\r\n this._isConnected = true;\r\n } catch (error) {\r\n this._isConnected = false;\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Closes the RabbitMQ connection if it is open.\r\n * If not connected, this method does nothing.\r\n * @throws {Error} If closing the connection fails.\r\n */\r\n async disconnect(): Promise<void> {\r\n if (!this._isConnected || !this._connection) {\r\n return;\r\n }\r\n\r\n try {\r\n await this._connection.close();\r\n this._isConnected = false;\r\n this._connection = null;\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Returns the active RabbitMQ connection.\r\n * @throws {Error} If the connection is not established.\r\n */\r\n get connection(): amqp.ChannelModel {\r\n if (!this._isConnected || !this._connection) {\r\n throw new Error(\"Connection is not established\");\r\n }\r\n return this._connection;\r\n }\r\n\r\n /**\r\n * Indicates whether the connector is currently connected to RabbitMQ.\r\n */\r\n get connected(): boolean {\r\n return this._isConnected;\r\n }\r\n\r\n /**\r\n * Returns the application ID associated with this connector.\r\n */\r\n get appId(): string {\r\n return this._appId;\r\n }\r\n\r\n get encoder(): RapidEncoder {\r\n return this._encoder;\r\n }\r\n}","/**\r\n * RapidEncoder Interface and Default Implementation\r\n * Provides methods to encode and decode messages for network transmission.\r\n */\r\nexport interface RapidEncoder {\r\n /**\r\n * Encodes a message to be sent over the network.\r\n * @param message - The message to encode.\r\n * @return {Promise<Buffer>} - The encoded message as a Buffer.\r\n */\r\n encode(message: unknown, exchange: string, topic: string): Promise<Buffer>;\r\n /**\r\n * Decodes a message received from the network.\r\n * @param data - The data to decode.\r\n * @return {Promise<unknown>} - The decoded message.\r\n */\r\n decode(data: Buffer, exchange: string, topic: string): Promise<unknown>;\r\n}\r\n\r\n/**\r\n * DefaultRapidEncoder provides a basic implementation of RapidEncoder.\r\n * It encodes messages as JSON strings and decodes them back to their original form.\r\n */\r\nexport class DefaultRapidEncoder implements RapidEncoder {\r\n async encode(message: unknown): Promise<Buffer> {\r\n let type: string = typeof message;\r\n let result;\r\n\r\n if (type === 'object' && message instanceof Date) {\r\n type = 'date';\r\n message = message.getTime();\r\n }\r\n\r\n result = JSON.stringify([type, message]);\r\n return Buffer.from(result, 'utf-8');\r\n }\r\n\r\n async decode(data: Buffer): Promise<unknown> {\r\n const [type, message] = JSON.parse(data.toString('utf-8'));\r\n switch (type) {\r\n case 'date':\r\n return new Date(message);\r\n default:\r\n return message;\r\n }\r\n }\r\n}","import { RapidConnector } from \"./rapid-connector\";\r\n\r\nexport interface MessagerOptions {\r\n /** The RapidConnector instance to use for RabbitMQ connection */\r\n connector: RapidConnector;\r\n\r\n /** (Optional) Name of the exchange to use for messaging */\r\n exchangeName?: string;\r\n\r\n /** (Optional) Name of the queue to use for messaging */\r\n durable?: boolean;\r\n\r\n /** (Optional) Whether the queue should be durable */\r\n exclusive?: boolean;\r\n}\r\n\r\nexport class Messager {\r\n constructor(\r\n protected _connector: RapidConnector,\r\n protected _exchangeName: string,\r\n protected _durable: boolean,\r\n protected _exclusive: boolean,\r\n ) {}\r\n\r\n public get connector(): RapidConnector {\r\n return this._connector;\r\n }\r\n\r\n public get exchangeName(): string {\r\n return this._exchangeName;\r\n }\r\n}","/**\r\n * PubSubMessager - Implements the publish/subscribe messaging pattern for RabbitMQ.\r\n * Part of the rapid-mq package.\r\n */\r\n\r\nimport * as amqp from 'amqplib';\r\n\r\nimport { Messager, MessagerOptions } from './messager';\r\n\r\n/**\r\n * Options for PubSubMessager.\r\n */\r\nexport interface PubSubMessagerOptions extends MessagerOptions {\r\n /**\r\n * Logical group for consumers.\r\n */\r\n appGroup: string;\r\n}\r\n\r\n/**\r\n * PubSubMessager - A class that implements the publish/subscribe messaging pattern using RabbitMQ.\r\n * It allows publishing messages to a topic and subscribing to messages from a topic.\r\n */\r\nexport class PubSubMessager extends Messager {\r\n private _appGroup: string;\r\n private _channel: amqp.Channel | null = null;\r\n\r\n constructor(options: PubSubMessagerOptions) {\r\n if (!options.connector) {\r\n throw new Error(\"RapidConnector is required\");\r\n }\r\n\r\n if (!options.appGroup) {\r\n throw new Error(\"App group is required\");\r\n }\r\n\r\n super(\r\n options.connector,\r\n options.exchangeName || 'pubsub-exchange',\r\n options.durable ?? true,\r\n options.exclusive ?? false,\r\n );\r\n this._appGroup = options.appGroup;\r\n }\r\n\r\n /**\r\n * The logical group for consumers.\r\n */\r\n get appGroup(): string {\r\n return this._appGroup;\r\n }\r\n\r\n /**\r\n * Prepare the messager for use by establishing a connection and creating a channel.\r\n * This method must be called before using the publish or subscribe methods.\r\n * @throws {Error} If the connection is not established.\r\n */\r\n async initialize(): Promise<void> {\r\n if (!this._connector.connected) {\r\n await this._connector.connect();\r\n }\r\n\r\n this._channel = await this._connector.connection.createChannel();\r\n if (!this._channel) {\r\n throw new Error(\"Connection is not established\");\r\n }\r\n\r\n await this._channel.assertExchange(this._exchangeName, 'topic', { durable: this._durable });\r\n }\r\n\r\n /**\r\n * Publish a message to a specific topic.\r\n * @param topic - The topic to publish the message to.\r\n * @param message - The message to publish. It can be any serializable object.\r\n * @param ttl - Optional time-to-live for the message in milliseconds.\r\n * @returns {boolean} - Returns true if the message was published successfully.\r\n * @throws {Error} - Throws an error if the channel is not initialized or if publishing fails.\r\n */\r\n async publish(topic: string, message: unknown, ttl?: number): Promise<boolean> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n const data = await this._connector.encoder.encode(message, this._exchangeName, topic);\r\n return this._channel.publish(this._exchangeName, topic, data, { expiration: ttl });\r\n }\r\n\r\n /**\r\n * Subscribe to a topic and process incoming messages with the provided callback.\r\n * @param topic - The topic to subscribe to.\r\n * @param callback - The function to call when a message is received.\r\n * @returns {Promise<void>} - Resolves when the subscription is set up.\r\n * @throws {Error} - Throws an error if the channel is not initialized.\r\n */\r\n async subscribe(topic: string, callback: (message: unknown) => void): Promise<void> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n const queue = await this._channel.assertQueue(`${this._appGroup}.${topic}`, { durable: this._durable, exclusive: this._exclusive });\r\n await this._channel.bindQueue(queue.queue, this._exchangeName, topic);\r\n await this._channel.bindQueue(queue.queue, this._exchangeName, `${this._appGroup}.${topic}`);\r\n\r\n this._channel.consume(queue.queue, async (msg) => {\r\n try {\r\n if (msg !== null) {\r\n const message = await this._connector.encoder.decode(msg.content, this._exchangeName, topic);\r\n await callback(message);\r\n }\r\n } catch (error) {\r\n console.error(\"Error processing message:\", error);\r\n }\r\n }, { noAck: true });\r\n }\r\n}","/**\r\n * RpcMessager - Implements the request/response (RPC) messaging pattern for RabbitMQ.\r\n * Allows sending RPC calls and serving RPC methods with automatic correlation and timeout handling.\r\n */\r\n\r\nimport * as crypto from 'crypto';\r\nimport { EventEmitter } from 'stream';\r\nimport * as amqp from 'amqplib';\r\n\r\nimport { Messager, MessagerOptions } from './messager';\r\n\r\n/**\r\n * Options for creating an RpcMessager instance.\r\n */\r\nexport interface RpcMessagerOptions extends MessagerOptions {\r\n /** (Optional) Timeout in seconds for RPC calls. Defaults to 5 seconds. */\r\n timeoutInSec?: number;\r\n /** (Optional) EventEmitter instance for handling RPC responses. Defaults to a new EventEmitter. */\r\n emitter?: EventEmitter;\r\n}\r\n\r\n/**\r\n * RpcMessager provides methods to make RPC calls and serve RPC endpoints using RabbitMQ.\r\n */\r\nexport class RpcMessager extends Messager {\r\n private _timeout: number;\r\n private _channel: amqp.Channel | null = null;\r\n private _responseQueue: string = 'amq.rabbitmq.reply-to';\r\n private _emitter:EventEmitter;\r\n\r\n /**\r\n * Constructs a new RpcMessager.\r\n * @param options - Configuration options for the messager.\r\n * @throws {Error} If connector is not provided.\r\n */\r\n constructor(options: RpcMessagerOptions) {\r\n if (!options.connector) {\r\n throw new Error(\"RapidConnector is required\");\r\n }\r\n\r\n super(\r\n options.connector,\r\n options.exchangeName || 'rpc-exchange',\r\n options.durable ?? true,\r\n options.exclusive ?? false,\r\n );\r\n this._timeout = (options.timeoutInSec || 5) * 1000;\r\n this._emitter = options.emitter || new EventEmitter();\r\n }\r\n\r\n /**\r\n * Initializes the RpcMessager by creating a channel, asserting the exchange,\r\n * and setting up a consumer for the reply-to queue.\r\n * @throws {Error} If the connection is not established.\r\n */\r\n async initialize(): Promise<void> {\r\n if (!this._connector.connected) {\r\n await this._connector.connect();\r\n }\r\n\r\n this._channel = await this._connector.connection.createChannel();\r\n if (!this._channel) {\r\n throw new Error(\"Connection is not established\");\r\n }\r\n\r\n await this._channel.assertExchange(this._exchangeName, 'direct', { durable: this._durable });\r\n\r\n this._channel.consume(this._responseQueue, (result) => {\r\n if (result && result.properties.correlationId) {\r\n this._emitter.emit(\r\n `rpc:${result.properties.correlationId}`,\r\n result.content,\r\n );\r\n }\r\n }, { noAck: true });\r\n }\r\n\r\n /**\r\n * Makes an RPC call to a remote method.\r\n * @param method - The name of the remote method (routing key).\r\n * @param args - Arguments to pass to the remote method.\r\n * @returns Promise<T> - Resolves with the response from the server.\r\n * @throws {Error} If the channel is not initialized or if the call times out.\r\n */\r\n async call<T>(method: string, ...args: unknown[]): Promise<T> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n return new Promise<T>(async (resolve, reject) => {\r\n const requestId = crypto.randomUUID();\r\n const data = await this._connector.encoder.encode(args, this._exchangeName, method);\r\n\r\n const timeout = setTimeout(() => {\r\n this._emitter.removeListener(`rpc:${requestId}`, responseHandler);\r\n reject(new Error(`RPC call to ${method} timed out after ${this._timeout / 1000} seconds`));\r\n }, this._timeout);\r\n\r\n const responseHandler = async (result: Buffer) => {\r\n clearTimeout(timeout);\r\n if (result) {\r\n const data = await this._connector.encoder.decode(result, this._exchangeName, method);\r\n resolve(data as T);\r\n }\r\n else reject(new Error(`No response received for RPC call to ${method}`));\r\n }\r\n\r\n this._emitter.once(`rpc:${requestId}`, responseHandler);\r\n\r\n this._channel!.publish(this._exchangeName, method, data, {\r\n replyTo: this._responseQueue,\r\n correlationId: requestId,\r\n expiration: this._timeout,\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Registers a server (handler) for an RPC method.\r\n * @param method - The name of the method to serve (routing key).\r\n * @param callback - The function to handle incoming RPC requests.\r\n * @returns Promise<void>\r\n * @throws {Error} If the channel is not initialized.\r\n */\r\n async server(method: string, callback: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n const queue = await this._channel.assertQueue(method, { durable: this._durable, exclusive: this._exclusive });\r\n await this._channel.bindQueue(queue.queue, this._exchangeName, method);\r\n\r\n this._channel.consume(queue.queue, async (msg) => {\r\n try {\r\n if (msg !== null) {\r\n const args = await this._connector.encoder.decode(msg.content, this._exchangeName, method) as unknown[];\r\n const result = await callback(...args);\r\n\r\n if (msg.properties.replyTo && msg.properties.correlationId) {\r\n this._channel!.sendToQueue(\r\n msg.properties.replyTo,\r\n await this._connector.encoder.encode(result, this._exchangeName, method),\r\n { correlationId: msg.properties.correlationId },\r\n );\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error processing RPC call for method ${method}:`, error);\r\n }\r\n }, { noAck: true });\r\n }\r\n}","/**\r\n * DirectMessager - A class for sending and receiving messages directly using RabbitMQ.\r\n * It allows sending messages to a specific consumer and listening for messages on a queue.\r\n */\r\n\r\nimport * as amqp from 'amqplib';\r\n\r\nimport { Messager, MessagerOptions } from './messager';\r\n\r\n/**\r\n * Options for DirectMessager.\r\n */\r\nexport interface DirectMessagerOptions extends MessagerOptions {\r\n /** Unique consumer tag for identifying the consumer. */\r\n consumerTag: string;\r\n}\r\n\r\n/**\r\n * DirectMessager - A class that implements direct messaging using RabbitMQ.\r\n * It allows sending messages to a specific consumer and listening for messages on a queue.\r\n */\r\nexport class DirectMessager extends Messager {\r\n private _consumerTag: string;\r\n private _channel: amqp.Channel | null = null;\r\n\r\n constructor(options: DirectMessagerOptions) {\r\n if (!options.connector) {\r\n throw new Error(\"RapidConnector is required\");\r\n }\r\n \r\n if (!options.consumerTag) {\r\n throw new Error(\"Consumer tag is required\");\r\n }\r\n \r\n super(\r\n options.connector,\r\n options.exchangeName || 'direct-exchange',\r\n options.durable ?? true,\r\n options.exclusive ?? false,\r\n );\r\n\r\n this._consumerTag = options.consumerTag;\r\n }\r\n\r\n /**\r\n * The unique consumer tag for identifying the consumer.\r\n */\r\n get consumerTag(): string {\r\n return this._consumerTag;\r\n }\r\n\r\n /**\r\n * Prepare the messager for use by establishing a connection and creating a channel.\r\n * This method must be called before using the publish or subscribe methods.\r\n */\r\n async initialize(): Promise<void> {\r\n if (!this._connector.connected) {\r\n await this._connector.connect();\r\n }\r\n\r\n this._channel = await this._connector.connection.createChannel();\r\n if (!this._channel) {\r\n throw new Error(\"Connection is not established\");\r\n }\r\n\r\n await this._channel.assertExchange(this._exchangeName, 'direct', { durable: this._durable });\r\n const queue = await this._channel.assertQueue(`${this._consumerTag}.queue`, { durable: this._durable, exclusive: this._exclusive });\r\n await this._channel.bindQueue(queue.queue, this._exchangeName, queue.queue);\r\n await this._channel.bindQueue(queue.queue, this._exchangeName, this._consumerTag);\r\n }\r\n\r\n /**\r\n * Send a message to a specific consumer.\r\n * @param sendTo - The consumer tag or queue name to send the message to.\r\n * @param message - The message to send.\r\n * @param ttl - Optional time-to-live for the message in milliseconds.\r\n * @returns {boolean} - A boolean true if the message was sent successfully, false otherwise.\r\n * @throws {Error} - Throws an error if the channel is not initialized or if publishing fails.\r\n */\r\n async send(sendTo: string, message: unknown, ttl?: number): Promise<boolean> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n const data = await this._connector.encoder.encode(message, this._exchangeName, sendTo);\r\n return this._channel.publish(this._exchangeName, sendTo, data, { expiration: ttl });\r\n }\r\n\r\n /**\r\n * Listen for messages on the consumer tag.\r\n * @param callback - A callback function that will be called with the received message.\r\n * @returns {Promise<void>} - A promise that resolves when the listener is set up.\r\n * @throws {Error} - Throws an error if the channel is not initialized.\r\n */\r\n async listen(callback: (message: unknown) => void): Promise<void> {\r\n if (!this._channel) {\r\n throw new Error(\"Channel is not initialized\");\r\n }\r\n\r\n await this._channel.consume(`${this._consumerTag}.queue`, async (msg) => {\r\n try {\r\n if (msg && msg.content) {\r\n const message = await this._connector.encoder.decode(msg.content, this._exchangeName, this._consumerTag);\r\n await callback(message);\r\n }\r\n } catch (error) {\r\n console.error(\"Error processing message:\", error);\r\n }\r\n }, { noAck: true });\r\n }\r\n}"],"mappings":"AAKA,UAAYA,MAAU,UCkBf,IAAMC,EAAN,KAAkD,CACrD,MAAM,OAAOC,EAAmC,CAC5C,IAAIC,EAAe,OAAOD,EACtBE,EAEJ,OAAID,IAAS,UAAYD,aAAmB,OACxCC,EAAO,OACPD,EAAUA,EAAQ,QAAQ,GAG9BE,EAAS,KAAK,UAAU,CAACD,EAAMD,CAAO,CAAC,EAChC,OAAO,KAAKE,EAAQ,OAAO,CACtC,CAEA,MAAM,OAAOC,EAAgC,CACzC,GAAM,CAACF,EAAMD,CAAO,EAAI,KAAK,MAAMG,EAAK,SAAS,OAAO,CAAC,EACzD,OAAQF,EAAM,CACV,IAAK,OACD,OAAO,IAAI,KAAKD,CAAO,EAC3B,QACI,OAAOA,CACf,CACJ,CACJ,EDvBO,IAAMI,EAAN,KAAqB,CAYxB,YAAoBC,EAAgC,CAAhC,aAAAA,EATpB,KAAQ,YAAwC,KAChD,KAAQ,aAAwB,GAS5B,GAAI,CAACA,EAAQ,IACT,MAAM,IAAI,MAAM,iBAAiB,EAGrC,GAAI,CAACA,EAAQ,MACT,MAAM,IAAI,MAAM,oBAAoB,EAGxC,KAAK,KAAOA,EAAQ,IACpB,KAAK,OAASA,EAAQ,MACtB,KAAK,SAAWA,EAAQ,SAAW,IAAIC,CAC3C,CAOA,MAAM,SAAyB,CAC3B,GAAI,MAAK,aAIT,GAAI,CACA,KAAK,YAAc,MAAW,UAAQ,KAAK,IAAI,EAC/C,KAAK,aAAe,EACxB,OAASC,EAAO,CACZ,WAAK,aAAe,GACdA,CACV,CACJ,CAOA,MAAM,YAA4B,CAC9B,GAAI,GAAC,KAAK,cAAgB,CAAC,KAAK,aAIhC,GAAI,CACA,MAAM,KAAK,YAAY,MAAM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","options","DefaultRapidEncoder","error","Messager","_connector","_exchangeName","_durable","_exclusive","PubSubMessager","Messager","options","topic","message","ttl","data","callback","queue","msg","error","crypto","EventEmitter","RpcMessager","Messager","options","EventEmitter","result","method","args","resolve","reject","requestId","data","timeout","responseHandler","callback","queue","msg","error","DirectMessager","Messager","options","queue","sendTo","message","ttl","data","callback","msg","error"]}