@opra/rabbitmq 1.15.0 → 1.15.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.
package/cjs/rabbitmq-adapter.js
CHANGED
|
@@ -134,14 +134,13 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
134
134
|
.consume(topic, async (msg) => {
|
|
135
135
|
if (!msg)
|
|
136
136
|
return;
|
|
137
|
-
await this.emitAsync('message', msg).catch(
|
|
137
|
+
await this.emitAsync('message', msg, topic).catch(noOp);
|
|
138
138
|
try {
|
|
139
139
|
await args.handler(channel, topic, msg);
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
|
142
142
|
this._emitError(e);
|
|
143
143
|
}
|
|
144
|
-
await this.emitAsync('message-finish', msg);
|
|
145
144
|
},
|
|
146
145
|
/** Consume options */
|
|
147
146
|
args.operationConfig.consumer)
|
|
@@ -276,11 +275,11 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
276
275
|
this._emitError(e, context);
|
|
277
276
|
return;
|
|
278
277
|
}
|
|
279
|
-
await this.emitAsync('
|
|
278
|
+
await this.emitAsync('execute', context).catch(noOp);
|
|
280
279
|
try {
|
|
281
280
|
/** Call operation handler */
|
|
282
281
|
const result = await operationHandler.call(instance, context);
|
|
283
|
-
await this.emitAsync('
|
|
282
|
+
await this.emitAsync('finish', context, result).catch(noOp);
|
|
284
283
|
}
|
|
285
284
|
catch (e) {
|
|
286
285
|
this._emitError(e, context);
|
|
@@ -339,7 +338,9 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
339
338
|
context.errors.push(error);
|
|
340
339
|
context.errors = this._wrapExceptions(context.errors);
|
|
341
340
|
if (context.listenerCount('error')) {
|
|
342
|
-
await context
|
|
341
|
+
await context
|
|
342
|
+
.emitAsync('error', context.errors[0], context)
|
|
343
|
+
.catch(noOp);
|
|
343
344
|
}
|
|
344
345
|
if (logger?.error) {
|
|
345
346
|
context.errors.forEach(err => logger.error(err));
|
|
@@ -348,7 +349,7 @@ class RabbitmqAdapter extends core_1.PlatformAdapter {
|
|
|
348
349
|
else
|
|
349
350
|
logger?.error(error);
|
|
350
351
|
if (this.listenerCount('error'))
|
|
351
|
-
this.
|
|
352
|
+
this._emitError(error, context);
|
|
352
353
|
})
|
|
353
354
|
.catch(noOp);
|
|
354
355
|
}
|
package/esm/rabbitmq-adapter.js
CHANGED
|
@@ -130,14 +130,13 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
130
130
|
.consume(topic, async (msg) => {
|
|
131
131
|
if (!msg)
|
|
132
132
|
return;
|
|
133
|
-
await this.emitAsync('message', msg).catch(
|
|
133
|
+
await this.emitAsync('message', msg, topic).catch(noOp);
|
|
134
134
|
try {
|
|
135
135
|
await args.handler(channel, topic, msg);
|
|
136
136
|
}
|
|
137
137
|
catch (e) {
|
|
138
138
|
this._emitError(e);
|
|
139
139
|
}
|
|
140
|
-
await this.emitAsync('message-finish', msg);
|
|
141
140
|
},
|
|
142
141
|
/** Consume options */
|
|
143
142
|
args.operationConfig.consumer)
|
|
@@ -272,11 +271,11 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
272
271
|
this._emitError(e, context);
|
|
273
272
|
return;
|
|
274
273
|
}
|
|
275
|
-
await this.emitAsync('
|
|
274
|
+
await this.emitAsync('execute', context).catch(noOp);
|
|
276
275
|
try {
|
|
277
276
|
/** Call operation handler */
|
|
278
277
|
const result = await operationHandler.call(instance, context);
|
|
279
|
-
await this.emitAsync('
|
|
278
|
+
await this.emitAsync('finish', context, result).catch(noOp);
|
|
280
279
|
}
|
|
281
280
|
catch (e) {
|
|
282
281
|
this._emitError(e, context);
|
|
@@ -335,7 +334,9 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
335
334
|
context.errors.push(error);
|
|
336
335
|
context.errors = this._wrapExceptions(context.errors);
|
|
337
336
|
if (context.listenerCount('error')) {
|
|
338
|
-
await context
|
|
337
|
+
await context
|
|
338
|
+
.emitAsync('error', context.errors[0], context)
|
|
339
|
+
.catch(noOp);
|
|
339
340
|
}
|
|
340
341
|
if (logger?.error) {
|
|
341
342
|
context.errors.forEach(err => logger.error(err));
|
|
@@ -344,7 +345,7 @@ export class RabbitmqAdapter extends PlatformAdapter {
|
|
|
344
345
|
else
|
|
345
346
|
logger?.error(error);
|
|
346
347
|
if (this.listenerCount('error'))
|
|
347
|
-
this.
|
|
348
|
+
this._emitError(error, context);
|
|
348
349
|
})
|
|
349
350
|
.catch(noOp);
|
|
350
351
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/rabbitmq",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "Opra RabbitMQ package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"@browsery/type-is": "^1.6.18-r8",
|
|
9
9
|
"content-type": "^1.0.5",
|
|
10
10
|
"iconv-lite": "^0.6.3",
|
|
11
|
-
"node-events-async": "^1.
|
|
11
|
+
"node-events-async": "^1.1.1",
|
|
12
12
|
"tslib": "^2.8.1",
|
|
13
13
|
"valgen": "^5.15.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@opra/common": "^1.15.
|
|
17
|
-
"@opra/core": "^1.15.
|
|
16
|
+
"@opra/common": "^1.15.1",
|
|
17
|
+
"@opra/core": "^1.15.1",
|
|
18
18
|
"amqplib": "^0.10.7"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
@@ -19,7 +19,7 @@ interface HandlerArguments {
|
|
|
19
19
|
*
|
|
20
20
|
* @class RabbitmqAdapter
|
|
21
21
|
*/
|
|
22
|
-
export declare class RabbitmqAdapter extends PlatformAdapter {
|
|
22
|
+
export declare class RabbitmqAdapter extends PlatformAdapter<RabbitmqAdapter.Events> {
|
|
23
23
|
static readonly PlatformName = "rabbitmq";
|
|
24
24
|
protected _config: RabbitmqAdapter.Config;
|
|
25
25
|
protected _controllerInstances: Map<RpcController, any>;
|
|
@@ -98,5 +98,11 @@ export declare namespace RabbitmqAdapter {
|
|
|
98
98
|
type IRabbitmqInterceptor = {
|
|
99
99
|
intercept(context: RabbitmqContext, next: NextCallback): Promise<any>;
|
|
100
100
|
};
|
|
101
|
+
interface Events {
|
|
102
|
+
error: [Error, RabbitmqContext | undefined];
|
|
103
|
+
execute: [RabbitmqContext];
|
|
104
|
+
finish: [RabbitmqContext, any];
|
|
105
|
+
message: [ConsumeMessage, string];
|
|
106
|
+
}
|
|
101
107
|
}
|
|
102
108
|
export {};
|