@lad-tech/nsc-toolkit 1.22.4 → 1.22.6
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 +2 -2
- package/dist/Service.js +5 -5
- package/dist/StreamManager.js +10 -1
- package/dist/types/StreamManager.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [1.22.
|
|
1
|
+
## [1.22.6](https://github.com/lad-tech/nsc-toolkit/compare/v1.22.5...v1.22.6) (2024-09-13)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Method sequential execution ([#126](https://github.com/lad-tech/nsc-toolkit/issues/126)) ([7f94aa3](https://github.com/lad-tech/nsc-toolkit/commit/7f94aa3b1c3ab5d786bb55b95cb5dd58d016750b))
|
package/dist/Service.js
CHANGED
|
@@ -393,13 +393,13 @@ class Service extends Root_1.Root {
|
|
|
393
393
|
this.subscriptions.push(subscription);
|
|
394
394
|
for await (const message of subscription) {
|
|
395
395
|
const { payload, baggage } = (0, nats_1.JSONCodec)().decode(message.data);
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
this.handled(payload, Method, baggage)
|
|
397
|
+
.then(result => {
|
|
398
398
|
message.respond(this.buildMessage(result));
|
|
399
|
-
}
|
|
400
|
-
|
|
399
|
+
})
|
|
400
|
+
.catch(error => {
|
|
401
401
|
message.respond(this.buildMessage({ error: error.message }));
|
|
402
|
-
}
|
|
402
|
+
});
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
405
|
if (this.httpMethods.size > 0) {
|
package/dist/StreamManager.js
CHANGED
|
@@ -13,6 +13,7 @@ class StreamManager extends Root_1.Root {
|
|
|
13
13
|
this.GREATER_WILDCARD = '>';
|
|
14
14
|
this.TWO_WEEKS_IN_SECOND = 1209600;
|
|
15
15
|
this.ONE_DAY_IN_SECOND = 86400;
|
|
16
|
+
this.CONSUMER_NOT_FOUND = 'consumer not found';
|
|
16
17
|
this.defaultStreamOption = {
|
|
17
18
|
storage: 'file',
|
|
18
19
|
retentionPolicy: 'limits',
|
|
@@ -105,7 +106,15 @@ class StreamManager extends Root_1.Root {
|
|
|
105
106
|
throw new Error(`Error creating consumer ${consumerName}. Stream for subject ${subject} not found`);
|
|
106
107
|
}
|
|
107
108
|
if ((0, types_1.isConsumerOptsBuilder)(options)) {
|
|
108
|
-
await this.jsm.consumers.
|
|
109
|
+
const isConsumerExist = await this.jsm.consumers.info(streamName, consumerName).catch(async (error) => {
|
|
110
|
+
if (error.message === this.CONSUMER_NOT_FOUND) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
});
|
|
115
|
+
if (!isConsumerExist) {
|
|
116
|
+
await this.jsm.consumers.add(streamName, { ...options.config, filter_subject: subject });
|
|
117
|
+
}
|
|
109
118
|
}
|
|
110
119
|
return isPullConsumer
|
|
111
120
|
? new StreamFetcher_1.StreamFetcher(this.broker.jetstream(), streamName, consumerName, {
|
|
@@ -8,6 +8,7 @@ export declare class StreamManager extends Root {
|
|
|
8
8
|
private readonly GREATER_WILDCARD;
|
|
9
9
|
private readonly TWO_WEEKS_IN_SECOND;
|
|
10
10
|
private readonly ONE_DAY_IN_SECOND;
|
|
11
|
+
private readonly CONSUMER_NOT_FOUND;
|
|
11
12
|
private readonly defaultStreamOption;
|
|
12
13
|
private jsm?;
|
|
13
14
|
constructor(param: StreamManagerParam);
|