Skip to content

Commit

Permalink
fix(amqp-service): rename connectionName to connectionToken
Browse files Browse the repository at this point in the history
  • Loading branch information
raschan committed Apr 26, 2022
1 parent c4204ce commit bc3b144
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/service/amqp/amqp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ export class AMQPService {
* ```
*
* @param {QueueModuleOptions} options Options for the module.
* @param {string} [connectionName] Name of the connection that is created
* @param {string} [connectionToken] Name of the connection that is created
*
* @return {Connection} The created `rhea-promise` Connection.
* @static
*/
public static async createConnection(
options: AMQPConnectionOptions,
connectionName: string = AMQP_DEFAULT_CONNECTION_TOKEN,
connectionToken: string = AMQP_DEFAULT_CONNECTION_TOKEN,
): Promise<Connection> {
if (Object.prototype.toString.call(options) !== '[object Object]') {
throw new Error('AMQPModule connection options must an object');
}

logger.log('creating AMQP client');
logger.log(`connection options: ${JSON.stringify(options)}, connection name: ${connectionName}`);
logger.log(`connection options: ${JSON.stringify(options)}, connection name: ${connectionToken}`);

const { throwExceptionOnConnectionError, connectionUri, connectionOptions: rheaConnectionOptions } = options;
const parsedConnectionUri = new URL(connectionUri);
Expand Down Expand Up @@ -139,7 +139,7 @@ export class AMQPService {
}
logger.log('created AMQP connection');

AMQConnectionStorage.add(connectionName, connection);
AMQConnectionStorage.add(connectionToken, connection);

return connection;
}
Expand Down Expand Up @@ -215,15 +215,15 @@ export class AMQPService {
* @param {string} source Name of the queue.
* @param {number} credits How many message can be processed parallel.
* @param {function(context: EventContext): Promise<void>} onMessage Function what will be invoked when a message arrives.
* @param {string} [connectionName] Name of the connection the receiver is on
* @param {string} [connectionToken] Name of the connection the receiver is on
*
* @return {Receiver} Receiver.
*/
public async createReceiver(
source: string | Source,
credits: number,
onMessage: (context: EventContext) => Promise<void>,
connectionName: string = AMQP_DEFAULT_CONNECTION_TOKEN,
connectionToken: string = AMQP_DEFAULT_CONNECTION_TOKEN,
): Promise<Receiver> {
const onError = (context: EventContext) => {
logger.error(
Expand All @@ -233,10 +233,10 @@ export class AMQPService {
);
};

const connection = AMQConnectionStorage.get(connectionName);
const connection = AMQConnectionStorage.get(connectionToken);

if (!connection) {
throw new Error(`No connection found for name ${connectionName}`);
throw new Error(`No connection found for name ${connectionToken}`);
}

const receiver: Receiver = await connection.createReceiver({
Expand Down

0 comments on commit bc3b144

Please sign in to comment.