@opra/kafka 1.14.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/kafka-adapter.js +6 -5
- package/esm/kafka-adapter.js +6 -5
- package/package.json +10 -7
- package/types/kafka-adapter.d.ts +8 -2
package/cjs/kafka-adapter.js
CHANGED
|
@@ -135,7 +135,6 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
135
135
|
this._emitError(e);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
await this.emitAsync('message-finish', payload);
|
|
139
138
|
},
|
|
140
139
|
})
|
|
141
140
|
.catch(e => {
|
|
@@ -347,11 +346,11 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
347
346
|
heartbeat,
|
|
348
347
|
pause,
|
|
349
348
|
});
|
|
350
|
-
await this.emitAsync('
|
|
349
|
+
await this.emitAsync('execute', context);
|
|
351
350
|
try {
|
|
352
351
|
/** Call operation handler */
|
|
353
352
|
const result = await operationHandler.call(instance, context);
|
|
354
|
-
await this.emitAsync('
|
|
353
|
+
await this.emitAsync('finish', context, result);
|
|
355
354
|
}
|
|
356
355
|
catch (e) {
|
|
357
356
|
this._emitError(e, context);
|
|
@@ -367,7 +366,9 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
367
366
|
context.errors.push(error);
|
|
368
367
|
context.errors = this._wrapExceptions(context.errors);
|
|
369
368
|
if (context.listenerCount('error')) {
|
|
370
|
-
await context
|
|
369
|
+
await context
|
|
370
|
+
.emitAsync('error', context.errors[0], context)
|
|
371
|
+
.catch(noOp);
|
|
371
372
|
}
|
|
372
373
|
if (logger?.error) {
|
|
373
374
|
context.errors.forEach(err => logger.error(err));
|
|
@@ -376,7 +377,7 @@ class KafkaAdapter extends core_1.PlatformAdapter {
|
|
|
376
377
|
else
|
|
377
378
|
logger?.error(error);
|
|
378
379
|
if (this.listenerCount('error'))
|
|
379
|
-
this.
|
|
380
|
+
this._emitError(error);
|
|
380
381
|
})
|
|
381
382
|
.catch(noOp);
|
|
382
383
|
}
|
package/esm/kafka-adapter.js
CHANGED
|
@@ -132,7 +132,6 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
132
132
|
this._emitError(e);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
await this.emitAsync('message-finish', payload);
|
|
136
135
|
},
|
|
137
136
|
})
|
|
138
137
|
.catch(e => {
|
|
@@ -344,11 +343,11 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
344
343
|
heartbeat,
|
|
345
344
|
pause,
|
|
346
345
|
});
|
|
347
|
-
await this.emitAsync('
|
|
346
|
+
await this.emitAsync('execute', context);
|
|
348
347
|
try {
|
|
349
348
|
/** Call operation handler */
|
|
350
349
|
const result = await operationHandler.call(instance, context);
|
|
351
|
-
await this.emitAsync('
|
|
350
|
+
await this.emitAsync('finish', context, result);
|
|
352
351
|
}
|
|
353
352
|
catch (e) {
|
|
354
353
|
this._emitError(e, context);
|
|
@@ -364,7 +363,9 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
364
363
|
context.errors.push(error);
|
|
365
364
|
context.errors = this._wrapExceptions(context.errors);
|
|
366
365
|
if (context.listenerCount('error')) {
|
|
367
|
-
await context
|
|
366
|
+
await context
|
|
367
|
+
.emitAsync('error', context.errors[0], context)
|
|
368
|
+
.catch(noOp);
|
|
368
369
|
}
|
|
369
370
|
if (logger?.error) {
|
|
370
371
|
context.errors.forEach(err => logger.error(err));
|
|
@@ -373,7 +374,7 @@ export class KafkaAdapter extends PlatformAdapter {
|
|
|
373
374
|
else
|
|
374
375
|
logger?.error(error);
|
|
375
376
|
if (this.listenerCount('error'))
|
|
376
|
-
this.
|
|
377
|
+
this._emitError(error);
|
|
377
378
|
})
|
|
378
379
|
.catch(noOp);
|
|
379
380
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/kafka",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "Opra Kafka package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"node-events-async": "^1.
|
|
8
|
+
"node-events-async": "^1.1.1",
|
|
9
9
|
"tslib": "^2.8.1",
|
|
10
|
-
"valgen": "^5.
|
|
10
|
+
"valgen": "^5.15.0"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/common": "^1.
|
|
14
|
-
"@opra/core": "^1.
|
|
13
|
+
"@opra/common": "^1.15.1",
|
|
14
|
+
"@opra/core": "^1.15.1",
|
|
15
15
|
"kafkajs": ">=2.2.4 <3"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"types": "./types/index.d.ts",
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
|
-
"url": "https://github.com/panates/opra.git",
|
|
37
|
+
"url": "git+https://github.com/panates/opra.git",
|
|
38
38
|
"directory": "packages/kafka"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
@@ -52,5 +52,8 @@
|
|
|
52
52
|
"opra",
|
|
53
53
|
"kafka",
|
|
54
54
|
"consumer"
|
|
55
|
-
]
|
|
55
|
+
],
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
}
|
|
56
59
|
}
|
package/types/kafka-adapter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiDocument, OpraException, OpraSchema, RpcApi, RpcController, RpcOperation } from '@opra/common';
|
|
2
2
|
import { type ILogger, PlatformAdapter } from '@opra/core';
|
|
3
|
-
import { type Consumer, type ConsumerConfig, type EachMessageHandler, Kafka, type KafkaConfig } from 'kafkajs';
|
|
3
|
+
import { type Consumer, type ConsumerConfig, type EachMessageHandler, EachMessagePayload, Kafka, type KafkaConfig } from 'kafkajs';
|
|
4
4
|
import type { StrictOmit } from 'ts-gems';
|
|
5
5
|
import { KafkaContext } from './kafka-context.js';
|
|
6
6
|
export interface OperationConfig {
|
|
@@ -21,7 +21,7 @@ interface HandlerArguments {
|
|
|
21
21
|
*
|
|
22
22
|
* @class KafkaAdapter
|
|
23
23
|
*/
|
|
24
|
-
export declare class KafkaAdapter extends PlatformAdapter {
|
|
24
|
+
export declare class KafkaAdapter extends PlatformAdapter<KafkaAdapter.Events> {
|
|
25
25
|
static readonly PlatformName = "kafka";
|
|
26
26
|
protected _config: KafkaAdapter.Config;
|
|
27
27
|
protected _controllerInstances: Map<RpcController, any>;
|
|
@@ -124,5 +124,11 @@ export declare namespace KafkaAdapter {
|
|
|
124
124
|
type IKafkaInterceptor = {
|
|
125
125
|
intercept(context: KafkaContext, next: NextCallback): Promise<any>;
|
|
126
126
|
};
|
|
127
|
+
interface Events {
|
|
128
|
+
error: [Error, KafkaContext | undefined];
|
|
129
|
+
finish: [KafkaContext, any];
|
|
130
|
+
execute: [KafkaContext];
|
|
131
|
+
message: [EachMessagePayload];
|
|
132
|
+
}
|
|
127
133
|
}
|
|
128
134
|
export {};
|