@opra/rabbitmq 1.17.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,6 +58,9 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
58
58
  get api() {
59
59
  return this.document.rpcApi;
60
60
  }
61
+ get connection() {
62
+ return this._connection;
63
+ }
61
64
  get scope() {
62
65
  return this._config.scope;
63
66
  }
@@ -74,10 +77,10 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
74
77
  // const handlerArgs: HandlerArguments[] = [];
75
78
  const configBuilder = new config_builder_js_1.ConfigBuilder(this.document, this._config);
76
79
  await configBuilder.build();
77
- this._client = new rabbit.Connection(configBuilder.connectionOptions);
80
+ this._connection = new rabbit.Connection(configBuilder.connectionOptions);
78
81
  try {
79
82
  /** Establish connection */
80
- await this._client.onConnect().catch(e => {
83
+ await this._connection.onConnect().catch(e => {
81
84
  e.message = `RabbitMQ connection error. ${e.message}`;
82
85
  throw e;
83
86
  });
@@ -88,7 +91,7 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
88
91
  for (const queue of args.topics) {
89
92
  const handler = this._createHandler(args);
90
93
  promises.push(new Promise((resolve, reject) => {
91
- const consumer = this._client.createConsumer({
94
+ const consumer = this._connection.createConsumer({
92
95
  ...args.consumerConfig,
93
96
  queueOptions: {
94
97
  ...args.consumerConfig.queueOptions,
@@ -131,8 +134,8 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
131
134
  async close() {
132
135
  if (this._consumers.length)
133
136
  await Promise.allSettled(this._consumers.map(consumer => consumer.close()));
134
- await this._client?.close();
135
- this._client = undefined;
137
+ await this._connection?.close();
138
+ this._connection = undefined;
136
139
  this._consumers = [];
137
140
  this._controllerInstances.clear();
138
141
  this._status = 'idle';
@@ -54,6 +54,9 @@ export class RabbitmqAdapter extends PlatformAdapter {
54
54
  get api() {
55
55
  return this.document.rpcApi;
56
56
  }
57
+ get connection() {
58
+ return this._connection;
59
+ }
57
60
  get scope() {
58
61
  return this._config.scope;
59
62
  }
@@ -70,10 +73,10 @@ export class RabbitmqAdapter extends PlatformAdapter {
70
73
  // const handlerArgs: HandlerArguments[] = [];
71
74
  const configBuilder = new ConfigBuilder(this.document, this._config);
72
75
  await configBuilder.build();
73
- this._client = new rabbit.Connection(configBuilder.connectionOptions);
76
+ this._connection = new rabbit.Connection(configBuilder.connectionOptions);
74
77
  try {
75
78
  /** Establish connection */
76
- await this._client.onConnect().catch(e => {
79
+ await this._connection.onConnect().catch(e => {
77
80
  e.message = `RabbitMQ connection error. ${e.message}`;
78
81
  throw e;
79
82
  });
@@ -84,7 +87,7 @@ export class RabbitmqAdapter extends PlatformAdapter {
84
87
  for (const queue of args.topics) {
85
88
  const handler = this._createHandler(args);
86
89
  promises.push(new Promise((resolve, reject) => {
87
- const consumer = this._client.createConsumer({
90
+ const consumer = this._connection.createConsumer({
88
91
  ...args.consumerConfig,
89
92
  queueOptions: {
90
93
  ...args.consumerConfig.queueOptions,
@@ -127,8 +130,8 @@ export class RabbitmqAdapter extends PlatformAdapter {
127
130
  async close() {
128
131
  if (this._consumers.length)
129
132
  await Promise.allSettled(this._consumers.map(consumer => consumer.close()));
130
- await this._client?.close();
131
- this._client = undefined;
133
+ await this._connection?.close();
134
+ this._connection = undefined;
132
135
  this._consumers = [];
133
136
  this._controllerInstances.clear();
134
137
  this._status = 'idle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/rabbitmq",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "Opra RabbitMQ package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -14,8 +14,8 @@
14
14
  "valgen": "^5.15.0"
15
15
  },
16
16
  "peerDependencies": {
17
- "@opra/common": "^1.17.0",
18
- "@opra/core": "^1.17.0",
17
+ "@opra/common": "^1.17.1",
18
+ "@opra/core": "^1.17.1",
19
19
  "rabbitmq-client": ">=5.0.0 <6"
20
20
  },
21
21
  "type": "module",
@@ -12,7 +12,7 @@ export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Eve
12
12
  static readonly PlatformName = "rabbitmq";
13
13
  protected _config: RabbitmqAdapter.Config;
14
14
  protected _controllerInstances: Map<RpcController, any>;
15
- protected _client?: rabbit.Connection;
15
+ protected _connection?: rabbit.Connection;
16
16
  protected _consumers: rabbit.Consumer[];
17
17
  protected _status: RabbitmqAdapter.Status;
18
18
  readonly protocol: OpraSchema.Transport;
@@ -26,6 +26,7 @@ export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Eve
26
26
  */
27
27
  constructor(document: ApiDocument, config: RabbitmqAdapter.Config);
28
28
  get api(): RpcApi;
29
+ get connection(): rabbit.Connection | undefined;
29
30
  get scope(): string | undefined;
30
31
  get status(): RabbitmqAdapter.Status;
31
32
  /**
@@ -54,7 +55,7 @@ export declare namespace RabbitmqAdapter {
54
55
  type NextCallback = () => Promise<any>;
55
56
  type ReplyFunction = (body: MessageBody, envelope?: Envelope) => Promise<void>;
56
57
  type Status = 'idle' | 'starting' | 'started';
57
- interface ConnectionOptions extends Pick<rabbit.ConnectionOptions, 'acquireTimeout' | 'connectionName' | 'frameMax' | 'heartbeat' | 'maxChannels' | 'retryHigh' | 'retryLow' | 'tls' | 'socket'> {
58
+ interface ConnectionOptions extends Pick<rabbit.ConnectionOptions, 'username' | 'password' | 'acquireTimeout' | 'connectionName' | 'connectionTimeout' | 'frameMax' | 'heartbeat' | 'maxChannels' | 'retryHigh' | 'retryLow' | 'noDelay' | 'tls' | 'socket'> {
58
59
  urls?: string[];
59
60
  }
60
61
  interface ConsumerConfig extends Pick<rabbit.ConsumerProps, 'concurrency' | 'requeue' | 'qos' | 'queueOptions' | 'exchanges' | 'exchangeBindings' | 'exclusive'> {