@lad-tech/nsc-toolkit 1.23.1 → 1.23.2

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 CHANGED
@@ -1,6 +1,6 @@
1
- ## [1.23.1](https://github.com/lad-tech/nsc-toolkit/compare/v1.23.0...v1.23.1) (2024-11-07)
1
+ ## [1.23.2](https://github.com/lad-tech/nsc-toolkit/compare/v1.23.1...v1.23.2) (2024-11-07)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * Grow subscriptions ([#129](https://github.com/lad-tech/nsc-toolkit/issues/129)) ([dd1945f](https://github.com/lad-tech/nsc-toolkit/commit/dd1945f9216840efd15db80dae915fa6eb22df1c))
6
+ * grow subscriptions ([#130](https://github.com/lad-tech/nsc-toolkit/issues/130)) ([d8b0ce2](https://github.com/lad-tech/nsc-toolkit/commit/d8b0ce26c2fab22b3eb9a5d28126fa8987c686e8))
package/dist/Client.js CHANGED
@@ -42,7 +42,7 @@ class Client extends Root_1.Root {
42
42
  async startBatchWatch(fetcher, listener, eventName) {
43
43
  while (true) {
44
44
  const batch = [];
45
- const events = fetcher.fetch();
45
+ const events = await fetcher.fetch();
46
46
  for await (const event of events) {
47
47
  let data;
48
48
  try {
@@ -58,7 +58,7 @@ class Client extends Root_1.Root {
58
58
  }
59
59
  if (batch.length > 0)
60
60
  listener.emit(eventName, batch);
61
- events.stop();
61
+ await events.close();
62
62
  }
63
63
  }
64
64
  getListener(serviceNameFrom, options) {
@@ -8,11 +8,11 @@ class StreamFetcher {
8
8
  this.consumerName = consumerName;
9
9
  this.options = options;
10
10
  }
11
- fetch(noWait, size, expires) {
12
- return this.jsClient.fetch(this.streamName, this.consumerName, {
13
- batch: size !== null && size !== void 0 ? size : this.options.batchSize,
11
+ async fetch(size, expires) {
12
+ const consumer = await this.jsClient.consumers.get(this.streamName, this.consumerName);
13
+ return await consumer.fetch({
14
+ max_messages: size !== null && size !== void 0 ? size : this.options.batchSize,
14
15
  expires: expires !== null && expires !== void 0 ? expires : this.options.batchTimeout,
15
- no_wait: noWait !== null && noWait !== void 0 ? noWait : this.options.noWait,
16
16
  });
17
17
  }
18
18
  }
@@ -1,4 +1,4 @@
1
- import { JetStreamClient, JsMsg, QueuedIterator } from 'nats';
1
+ import { ConsumerMessages, JetStreamClient } from 'nats';
2
2
  interface BatcherOptions {
3
3
  batchSize?: number;
4
4
  batchTimeout?: number;
@@ -10,6 +10,6 @@ export declare class StreamFetcher {
10
10
  private consumerName;
11
11
  private options;
12
12
  constructor(jsClient: JetStreamClient, streamName: string, consumerName: string, options: BatcherOptions);
13
- fetch(noWait?: boolean, size?: number, expires?: number): QueuedIterator<JsMsg>;
13
+ fetch(size?: number, expires?: number): Promise<ConsumerMessages>;
14
14
  }
15
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.23.1",
3
+ "version": "1.23.2",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",