@lad-tech/nsc-toolkit 1.23.2 → 1.24.0
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/CHANGELOG.md +3 -3
- package/dist/Client.js +0 -1
- package/dist/Service.js +12 -2
- package/dist/types/Service.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.24.0](https://github.com/lad-tech/nsc-toolkit/compare/v1.23.3...v1.24.0) (2024-11-08)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Uniq key for event ([#133](https://github.com/lad-tech/nsc-toolkit/issues/133)) ([ff69a67](https://github.com/lad-tech/nsc-toolkit/commit/ff69a67b464f64e9eebb44e2c65bb626c30b68ea))
|
package/dist/Client.js
CHANGED
package/dist/Service.js
CHANGED
|
@@ -25,12 +25,17 @@ class Service extends Root_1.Root {
|
|
|
25
25
|
this.subscriptions = [];
|
|
26
26
|
this.httpMethods = new Map();
|
|
27
27
|
this.rootSpans = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Unique identifier NATS header for a message that will be used by the server apply
|
|
30
|
+
* de-duplication within the configured Duplicate Window
|
|
31
|
+
*/
|
|
32
|
+
this.UNIQ_ID_HEADER = 'Nats-Msg-Id';
|
|
28
33
|
this.serviceName = options.name;
|
|
29
34
|
this.logger.setLocation(this.serviceName);
|
|
30
35
|
if (options.events) {
|
|
31
36
|
const events = Object.keys(options.events.list);
|
|
32
37
|
this.emitter = events.reduce((result, eventName) => {
|
|
33
|
-
result[eventName] = ((params) => {
|
|
38
|
+
result[eventName] = ((params, uniqId) => {
|
|
34
39
|
var _a, _b, _c;
|
|
35
40
|
const subject = [options.name];
|
|
36
41
|
const eventOptions = (_a = options.events) === null || _a === void 0 ? void 0 : _a.list[eventName];
|
|
@@ -42,7 +47,12 @@ class Service extends Root_1.Root {
|
|
|
42
47
|
subject.push(prefix);
|
|
43
48
|
}
|
|
44
49
|
subject.push(String(eventName));
|
|
45
|
-
|
|
50
|
+
let settings;
|
|
51
|
+
if (uniqId) {
|
|
52
|
+
settings = { headers: (0, nats_1.headers)() };
|
|
53
|
+
settings.headers.append(this.UNIQ_ID_HEADER, uniqId);
|
|
54
|
+
}
|
|
55
|
+
this.broker.publish(subject.join('.'), this.buildMessage(params), settings);
|
|
46
56
|
});
|
|
47
57
|
return result;
|
|
48
58
|
}, this.emitter);
|
package/dist/types/Service.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare class Service<E extends Emitter = Emitter> extends Root {
|
|
|
11
11
|
private subscriptions;
|
|
12
12
|
private httpMethods;
|
|
13
13
|
private rootSpans;
|
|
14
|
+
/**
|
|
15
|
+
* Unique identifier NATS header for a message that will be used by the server apply
|
|
16
|
+
* de-duplication within the configured Duplicate Window
|
|
17
|
+
*/
|
|
18
|
+
private readonly UNIQ_ID_HEADER;
|
|
14
19
|
constructor(options: ServiceOptions<E>);
|
|
15
20
|
/**
|
|
16
21
|
* Create global Tracer
|