rapid-mq
Version:
A simple and fast RabbitMQ client for Node.js
1 lines • 29 kB
Source Map (JSON)
{"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":["/**\n * RapidConnector - Handles connection management to RabbitMQ for the rapid-mq package.\n * Provides methods to connect, disconnect, and access the underlying connection.\n */\n\nimport * as amqp from 'amqplib';\nimport { DefaultRapidEncoder, RapidEncoder } from './rapic-encoder';\n\n/**\n * Options for creating a RapidConnector instance.\n */\nexport interface RapidConnectorOptions {\n /** The RabbitMQ connection URL (e.g., amqp://user:pass@host:port/vhost) */\n url: string;\n /** Unique application identifier for this connector */\n appId: string;\n /** Optional encoder for message serialization */\n encoder?: RapidEncoder;\n}\n\n/**\n * RapidConnector provides a simple interface to manage a RabbitMQ connection.\n */\nexport class RapidConnector {\n private _url: string;\n private _appId: string;\n private _connection: amqp.ChannelModel | null = null;\n private _isConnected: boolean = false;\n private _encoder: RapidEncoder;\n private _initPromise?: Promise<void>;\n\n /**\n * Constructs a new RapidConnector.\n * @param options - Configuration options for the connector.\n * @throws {Error} If url or appId is not provided.\n */\n constructor(private options: RapidConnectorOptions) {\n if (!options.url) {\n throw new Error(\"URL is required\");\n }\n\n if (!options.appId) {\n throw new Error(\"App ID is required\");\n }\n\n this._url = options.url;\n this._appId = options.appId;\n this._encoder = options.encoder || new DefaultRapidEncoder();\n }\n\n /**\n * Establishes a connection to RabbitMQ.\n * If already connected, this method does nothing.\n * @throws {Error} If the connection fails.\n */\n async connect(): Promise<void> {\n if (this._isConnected) return;\n if (this._initPromise) return await this._initPromise;\n\n this._initPromise = (async () => {\n try {\n this._connection = await amqp.connect(this._url);\n this._isConnected = true;\n } catch (error) {\n this._isConnected = false;\n throw error;\n }\n })();\n \n return await this._initPromise;\n }\n\n /**\n * Closes the RabbitMQ connection if it is open.\n * If not connected, this method does nothing.\n * @throws {Error} If closing the connection fails.\n */\n async disconnect(): Promise<void> {\n if (!this._isConnected || !this._connection) {\n return;\n }\n\n try {\n await this._connection.close();\n this._isConnected = false;\n this._connection = null;\n } catch (error) {\n throw error;\n }\n }\n\n /**\n * Returns the active RabbitMQ connection.\n * @throws {Error} If the connection is not established.\n */\n get connection(): amqp.ChannelModel {\n if (!this._isConnected || !this._connection) {\n throw new Error(\"Connection is not established\");\n }\n return this._connection;\n }\n\n /**\n * Indicates whether the connector is currently connected to RabbitMQ.\n */\n get connected(): boolean {\n return this._isConnected;\n }\n\n /**\n * Returns the application ID associated with this connector.\n */\n get appId(): string {\n return this._appId;\n }\n\n get encoder(): RapidEncoder {\n return this._encoder;\n }\n}","/**\n * RapidEncoder Interface and Default Implementation\n * Provides methods to encode and decode messages for network transmission.\n */\nexport interface RapidEncoder {\n /**\n * Encodes a message to be sent over the network.\n * @param message - The message to encode.\n * @return {Promise<Buffer>} - The encoded message as a Buffer.\n */\n encode(message: unknown, exchange: string, topic: string): Promise<Buffer>;\n /**\n * Decodes a message received from the network.\n * @param data - The data to decode.\n * @return {Promise<unknown>} - The decoded message.\n */\n decode(data: Buffer, exchange: string, topic: string): Promise<unknown>;\n}\n\n/**\n * DefaultRapidEncoder provides a basic implementation of RapidEncoder.\n * It encodes messages as JSON strings and decodes them back to their original form.\n */\nexport class DefaultRapidEncoder implements RapidEncoder {\n async encode(message: unknown): Promise<Buffer> {\n let type: string = typeof message;\n let result;\n\n if (type === 'object' && message instanceof Date) {\n type = 'date';\n message = message.getTime();\n }\n\n result = JSON.stringify([type, message]);\n return Buffer.from(result, 'utf-8');\n }\n\n async decode(data: Buffer): Promise<unknown> {\n const [type, message] = JSON.parse(data.toString('utf-8'));\n switch (type) {\n case 'date':\n return new Date(message);\n default:\n return message;\n }\n }\n}","import { RapidConnector } from \"./rapid-connector\";\n\nexport interface MessagerOptions {\n /** The RapidConnector instance to use for RabbitMQ connection */\n connector: RapidConnector;\n\n /** (Optional) Name of the exchange to use for messaging */\n exchangeName?: string;\n\n /** (Optional) Name of the queue to use for messaging */\n durable?: boolean;\n\n /** (Optional) Whether the queue should be durable */\n exclusive?: boolean;\n}\n\nexport class Messager {\n constructor(\n protected _connector: RapidConnector,\n protected _exchangeName: string,\n protected _durable: boolean,\n protected _exclusive: boolean,\n ) {}\n\n public get connector(): RapidConnector {\n return this._connector;\n }\n\n public get exchangeName(): string {\n return this._exchangeName;\n }\n}","/**\n * PubSubMessager - Implements the publish/subscribe messaging pattern for RabbitMQ.\n * Part of the rapid-mq package.\n */\n\nimport * as amqp from 'amqplib';\n\nimport { Messager, MessagerOptions } from './messager';\n\n/**\n * Options for PubSubMessager.\n */\nexport interface PubSubMessagerOptions extends MessagerOptions {\n /**\n * Logical group for consumers.\n */\n appGroup: string;\n}\n\n/**\n * PubSubMessager - A class that implements the publish/subscribe messaging pattern using RabbitMQ.\n * It allows publishing messages to a topic and subscribing to messages from a topic.\n */\nexport class PubSubMessager extends Messager {\n private _appGroup: string;\n private _channel: amqp.Channel | null = null;\n private _initPromise?: Promise<void>;\n\n constructor(options: PubSubMessagerOptions) {\n if (!options.connector) {\n throw new Error(\"RapidConnector is required\");\n }\n\n if (!options.appGroup) {\n throw new Error(\"App group is required\");\n }\n\n super(\n options.connector,\n options.exchangeName || 'pubsub-exchange',\n options.durable ?? true,\n options.exclusive ?? false,\n );\n this._appGroup = options.appGroup;\n }\n\n /**\n * The logical group for consumers.\n */\n get appGroup(): string {\n return this._appGroup;\n }\n\n /**\n * Prepare the messager for use by establishing a connection and creating a channel.\n * This method must be called before using the publish or subscribe methods.\n * @throws {Error} If the connection is not established.\n */\n async initialize(): Promise<void> {\n if (this._channel) return;\n if (this._initPromise) return await this._initPromise;\n\n this._initPromise = (async () => {\n if (!this._connector.connected) {\n await this._connector.connect();\n }\n\n const channel = await this._connector.connection.createChannel();\n if (!channel) {\n throw new Error(\"Connection is not established\");\n }\n\n channel.assertExchange(this._exchangeName, 'topic', { durable: this._durable });\n this._channel = channel;\n })();\n\n return await this._initPromise;\n }\n\n /**\n * Publish a message to a specific topic.\n * @param topic - The topic to publish the message to.\n * @param message - The message to publish. It can be any serializable object.\n * @param ttl - Optional time-to-live for the message in milliseconds.\n * @returns {boolean} - Returns true if the message was published successfully.\n * @throws {Error} - Throws an error if the channel is not initialized or if publishing fails.\n */\n async publish(topic: string, message: unknown, ttl?: number): Promise<boolean> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n const data = await this._connector.encoder.encode(message, this._exchangeName, topic);\n return this._channel.publish(this._exchangeName, topic, data, { expiration: ttl });\n }\n\n /**\n * Subscribe to a topic and process incoming messages with the provided callback.\n * @param topic - The topic to subscribe to.\n * @param callback - The function to call when a message is received.\n * @returns {Promise<void>} - Resolves when the subscription is set up.\n * @throws {Error} - Throws an error if the channel is not initialized.\n */\n async subscribe(topic: string, callback: (message: unknown) => void): Promise<void> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n const queue = await this._channel.assertQueue(`${this._appGroup}.${topic}`, { durable: this._durable, exclusive: this._exclusive });\n await this._channel.bindQueue(queue.queue, this._exchangeName, topic);\n await this._channel.bindQueue(queue.queue, this._exchangeName, `${this._appGroup}.${topic}`);\n\n this._channel.consume(queue.queue, async (msg) => {\n try {\n if (msg !== null) {\n const message = await this._connector.encoder.decode(msg.content, this._exchangeName, topic);\n await callback(message);\n }\n } catch (error) {\n console.error(\"Error processing message:\", error);\n }\n }, { noAck: true });\n }\n}","/**\n * RpcMessager - Implements the request/response (RPC) messaging pattern for RabbitMQ.\n * Allows sending RPC calls and serving RPC methods with automatic correlation and timeout handling.\n */\n\nimport * as crypto from 'crypto';\nimport { EventEmitter } from 'stream';\nimport * as amqp from 'amqplib';\n\nimport { Messager, MessagerOptions } from './messager';\n\n/**\n * Options for creating an RpcMessager instance.\n */\nexport interface RpcMessagerOptions extends MessagerOptions {\n /** (Optional) Timeout in seconds for RPC calls. Defaults to 5 seconds. */\n timeoutInSec?: number;\n /** (Optional) EventEmitter instance for handling RPC responses. Defaults to a new EventEmitter. */\n emitter?: EventEmitter;\n}\n\n/**\n * RpcMessager provides methods to make RPC calls and serve RPC endpoints using RabbitMQ.\n */\nexport class RpcMessager extends Messager {\n private _timeout: number;\n private _channel: amqp.Channel | null = null;\n private _responseQueue: string = 'amq.rabbitmq.reply-to';\n private _emitter:EventEmitter;\n private _initPromise?: Promise<void>;\n\n /**\n * Constructs a new RpcMessager.\n * @param options - Configuration options for the messager.\n * @throws {Error} If connector is not provided.\n */\n constructor(options: RpcMessagerOptions) {\n if (!options.connector) {\n throw new Error(\"RapidConnector is required\");\n }\n\n super(\n options.connector,\n options.exchangeName || 'rpc-exchange',\n options.durable ?? true,\n options.exclusive ?? false,\n );\n this._timeout = (options.timeoutInSec || 5) * 1000;\n this._emitter = options.emitter || new EventEmitter();\n }\n\n /**\n * Initializes the RpcMessager by creating a channel, asserting the exchange,\n * and setting up a consumer for the reply-to queue.\n * @throws {Error} If the connection is not established.\n */\n async initialize(): Promise<void> {\n if (this._channel) return;\n if (this._initPromise) return await this._initPromise;\n\n this._initPromise = (async () => {\n if (!this._connector.connected) {\n await this._connector.connect();\n }\n\n const channel = await this._connector.connection.createChannel();\n if (!this._channel) {\n throw new Error(\"Connection is not established\");\n }\n\n await channel.assertExchange(this._exchangeName, 'direct', { durable: this._durable });\n await channel.consume(this._responseQueue, (result) => {\n if (result && result.properties.correlationId) {\n this._emitter.emit(\n `rpc:${result.properties.correlationId}`,\n result.content,\n );\n }\n }, { noAck: true });\n this._channel = channel;\n })();\n\n return await this._initPromise;\n }\n\n /**\n * Makes an RPC call to a remote method.\n * @param method - The name of the remote method (routing key).\n * @param args - Arguments to pass to the remote method.\n * @returns Promise<T> - Resolves with the response from the server.\n * @throws {Error} If the channel is not initialized or if the call times out.\n */\n async call<T>(method: string, ...args: unknown[]): Promise<T> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n return new Promise<T>(async (resolve, reject) => {\n const requestId = crypto.randomUUID();\n const data = await this._connector.encoder.encode(args, this._exchangeName, method);\n\n const timeout = setTimeout(() => {\n this._emitter.removeListener(`rpc:${requestId}`, responseHandler);\n reject(new Error(`RPC call to ${method} timed out after ${this._timeout / 1000} seconds`));\n }, this._timeout);\n\n const responseHandler = async (result: Buffer) => {\n clearTimeout(timeout);\n if (result) {\n const data = await this._connector.encoder.decode(result, this._exchangeName, method);\n resolve(data as T);\n }\n else reject(new Error(`No response received for RPC call to ${method}`));\n }\n\n this._emitter.once(`rpc:${requestId}`, responseHandler);\n\n this._channel!.publish(this._exchangeName, method, data, {\n replyTo: this._responseQueue,\n correlationId: requestId,\n expiration: this._timeout,\n });\n });\n }\n\n /**\n * Registers a server (handler) for an RPC method.\n * @param method - The name of the method to serve (routing key).\n * @param callback - The function to handle incoming RPC requests.\n * @returns Promise<void>\n * @throws {Error} If the channel is not initialized.\n */\n async server(method: string, callback: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n const queue = await this._channel.assertQueue(method, { durable: this._durable, exclusive: this._exclusive });\n await this._channel.bindQueue(queue.queue, this._exchangeName, method);\n\n this._channel.consume(queue.queue, async (msg) => {\n try {\n if (msg !== null) {\n const args = await this._connector.encoder.decode(msg.content, this._exchangeName, method) as unknown[];\n const result = await callback(...args);\n\n if (msg.properties.replyTo && msg.properties.correlationId) {\n this._channel!.sendToQueue(\n msg.properties.replyTo,\n await this._connector.encoder.encode(result, this._exchangeName, method),\n { correlationId: msg.properties.correlationId },\n );\n }\n }\n } catch (error) {\n console.error(`Error processing RPC call for method ${method}:`, error);\n }\n }, { noAck: true });\n }\n}","/**\n * DirectMessager - A class for sending and receiving messages directly using RabbitMQ.\n * It allows sending messages to a specific consumer and listening for messages on a queue.\n */\n\nimport * as amqp from 'amqplib';\n\nimport { Messager, MessagerOptions } from './messager';\n\n/**\n * Options for DirectMessager.\n */\nexport interface DirectMessagerOptions extends MessagerOptions {\n /** Unique consumer tag for identifying the consumer. */\n consumerTag: string;\n}\n\n/**\n * DirectMessager - A class that implements direct messaging using RabbitMQ.\n * It allows sending messages to a specific consumer and listening for messages on a queue.\n */\nexport class DirectMessager extends Messager {\n private _consumerTag: string;\n private _channel: amqp.Channel | null = null;\n private _initPromise?: Promise<void>;\n\n constructor(options: DirectMessagerOptions) {\n if (!options.connector) {\n throw new Error(\"RapidConnector is required\");\n }\n \n if (!options.consumerTag) {\n throw new Error(\"Consumer tag is required\");\n }\n \n super(\n options.connector,\n options.exchangeName || 'direct-exchange',\n options.durable ?? true,\n options.exclusive ?? false,\n );\n\n this._consumerTag = options.consumerTag;\n }\n\n /**\n * The unique consumer tag for identifying the consumer.\n */\n get consumerTag(): string {\n return this._consumerTag;\n }\n\n /**\n * Prepare the messager for use by establishing a connection and creating a channel.\n * This method must be called before using the publish or subscribe methods.\n */\n async initialize(): Promise<void> {\n if (this._channel) return;\n if (this._initPromise) return await this._initPromise;\n\n this._initPromise = (async () => {\n if (!this._connector.connected) {\n await this._connector.connect();\n }\n\n const channel = await this._connector.connection.createChannel();\n if (!channel) {\n throw new Error(\"Connection is not established\");\n }\n\n await channel.assertExchange(this._exchangeName, 'direct', { durable: this._durable });\n const queue = await channel.assertQueue(`${this._consumerTag}.queue`, { durable: this._durable, exclusive: this._exclusive });\n await channel.bindQueue(queue.queue, this._exchangeName, queue.queue);\n await channel.bindQueue(queue.queue, this._exchangeName, this._consumerTag);\n this._channel = channel;\n })();\n\n return await this._initPromise;\n }\n\n /**\n * Send a message to a specific consumer.\n * @param sendTo - The consumer tag or queue name to send the message to.\n * @param message - The message to send.\n * @param ttl - Optional time-to-live for the message in milliseconds.\n * @returns {boolean} - A boolean true if the message was sent successfully, false otherwise.\n * @throws {Error} - Throws an error if the channel is not initialized or if publishing fails.\n */\n async send(sendTo: string, message: unknown, ttl?: number): Promise<boolean> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n const data = await this._connector.encoder.encode(message, this._exchangeName, sendTo);\n return this._channel.publish(this._exchangeName, sendTo, data, { expiration: ttl });\n }\n\n /**\n * Listen for messages on the consumer tag.\n * @param callback - A callback function that will be called with the received message.\n * @returns {Promise<void>} - A promise that resolves when the listener is set up.\n * @throws {Error} - Throws an error if the channel is not initialized.\n */\n async listen(callback: (message: unknown) => void): Promise<void> {\n if (!this._channel) {\n throw new Error(\"Channel is not initialized\");\n }\n\n await this._channel.consume(`${this._consumerTag}.queue`, async (msg) => {\n try {\n if (msg && msg.content) {\n const message = await this._connector.encoder.decode(msg.content, this._exchangeName, this._consumerTag);\n await callback(message);\n }\n } catch (error) {\n console.error(\"Error processing message:\", error);\n }\n }, { noAck: true });\n }\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,CAaxB,YAAoBC,EAAgC,CAAhC,aAAAA,EAVpB,KAAQ,YAAwC,KAChD,KAAQ,aAAwB,GAU5B,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,CA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kBC,EAAgC,CACzE,GAAI,CAAC,KAAK,SACN,MAAM,IAAI,MAAM,4BAA4B,EAGhD,IAAMC,EAAO,MAAM,KAAK,WAAW,QAAQ,OAAOF,EAAS,KAAK,cAAeD,CAAM,EACrF,OAAO,KAAK,SAAS,QAAQ,KAAK,cAAeA,EAAQG,EAAM,CAAE,WAAYD,CAAI,CAAC,CACtF,CAQA,MAAM,OAAOE,EAAqD,CAC9D,GAAI,CAAC,KAAK,SACN,MAAM,IAAI,MAAM,4BAA4B,EAGhD,MAAM,KAAK,SAAS,QAAQ,GAAG,KAAK,YAAY,SAAU,MAAOC,GAAQ,CACrE,GAAI,CACA,GAAIA,GAAOA,EAAI,QAAS,CACpB,IAAMJ,EAAU,MAAM,KAAK,WAAW,QAAQ,OAAOI,EAAI,QAAS,KAAK,cAAe,KAAK,YAAY,EACvG,MAAMD,EAASH,CAAO,CAC1B,CACJ,OAASK,EAAO,CACZ,QAAQ,MAAM,4BAA6BA,CAAK,CACpD,CACJ,EAAG,CAAE,MAAO,EAAK,CAAC,CACtB,CACJ","names":["amqp","DefaultRapidEncoder","message","type","result","data","RapidConnector","options","DefaultRapidEncoder","error","Messager","_connector","_exchangeName","_durable","_exclusive","PubSubMessager","Messager","options","channel","topic","message","ttl","data","callback","queue","msg","error","crypto","EventEmitter","RpcMessager","Messager","options","EventEmitter","channel","result","method","args","resolve","reject","requestId","data","timeout","responseHandler","callback","queue","msg","error","DirectMessager","Messager","options","channel","queue","sendTo","message","ttl","data","callback","msg","error"]}