Skip to content

Commit

Permalink
feat(microservices): add type for rmq connection options
Browse files Browse the repository at this point in the history
change socketOptions.connectionOptions type from any to amqp-manager's AmqpConnectionOptions which allows to specify not only mTLS but also External auth

Closes #13071
  • Loading branch information
Deniks committed Jan 27, 2024
1 parent 95e8b94 commit d637bd4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/microservices/client/client-rmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type ChannelWrapper = any;
type ConsumeMessage = any;
type AmqpConnectionManager = any;

let rqmPackage: any = {};
let rmqPackage: any = {};

const REPLY_QUEUE = 'amq.rabbitmq.reply-to';

Expand Down Expand Up @@ -81,7 +81,7 @@ export class ClientRMQ extends ClientProxy {
this.getOptionsProp(this.options, 'noAssert') || RQM_DEFAULT_NO_ASSERT;

loadPackage('amqplib', ClientRMQ.name, () => require('amqplib'));
rqmPackage = loadPackage('amqp-connection-manager', ClientRMQ.name, () =>
rmqPackage = loadPackage('amqp-connection-manager', ClientRMQ.name, () =>
require('amqp-connection-manager'),
);

Expand Down Expand Up @@ -133,7 +133,7 @@ export class ClientRMQ extends ClientProxy {

public createClient(): AmqpConnectionManager {
const socketOptions = this.getOptionsProp(this.options, 'socketOptions');
return rqmPackage.connect(this.urls, {
return rmqPackage.connect(this.urls, {
connectionOptions: socketOptions,
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/microservices/external/rmq-url.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AmqpConnectionManager } from 'amqp-connection-manager';

/**
* @publicApi
*/
Expand Down Expand Up @@ -25,7 +27,7 @@ export interface AmqpConnectionManagerSocketOptions {
reconnectTimeInSeconds?: number;
heartbeatIntervalInSeconds?: number;
findServers?: () => string | string[];
connectionOptions?: any;
connectionOptions?: AmqpConnectionManager['connectionOptions'];
clientProperties?: ClientProperties;
[key: string]: any;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/microservices/server/server-rmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { RmqRecordSerializer } from '../serializers/rmq-record.serializer';
import { Server } from './server';

let rqmPackage: any = {};
let rmqPackage: any = {};

const INFINITE_CONNECTION_ATTEMPTS = -1;

Expand Down Expand Up @@ -67,7 +67,7 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
this.getOptionsProp(this.options, 'noAssert') || RQM_DEFAULT_NO_ASSERT;

this.loadPackage('amqplib', ServerRMQ.name, () => require('amqplib'));
rqmPackage = this.loadPackage(
rmqPackage = this.loadPackage(
'amqp-connection-manager',
ServerRMQ.name,
() => require('amqp-connection-manager'),
Expand Down Expand Up @@ -136,7 +136,7 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {

public createClient<T = any>(): T {
const socketOptions = this.getOptionsProp(this.options, 'socketOptions');
return rqmPackage.connect(this.urls, {
return rmqPackage.connect(this.urls, {
connectionOptions: socketOptions,
heartbeatIntervalInSeconds: socketOptions?.heartbeatIntervalInSeconds,
reconnectTimeInSeconds: socketOptions?.reconnectTimeInSeconds,
Expand Down

0 comments on commit d637bd4

Please sign in to comment.