@aichatwar/shared 1.0.126 → 1.0.127

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.
@@ -6,6 +6,7 @@ export declare abstract class Listener<T extends BaseEvent> {
6
6
  abstract onMessage(data: T['data'], payload: EachMessagePayload): Promise<void>;
7
7
  protected consumer: Consumer;
8
8
  protected ackDeadline: number;
9
+ protected fromBeginning: boolean;
9
10
  private currentPayload?;
10
11
  private retryCount;
11
12
  private readonly maxInitialRetries;
@@ -13,6 +13,7 @@ exports.Listener = void 0;
13
13
  class Listener {
14
14
  constructor(consumer) {
15
15
  this.ackDeadline = 5 * 1000; // 5 seconds
16
+ this.fromBeginning = false; // Override in subclasses to read from beginning
16
17
  this.retryCount = 0;
17
18
  this.maxInitialRetries = 3; // Show detailed retry logs for first 3 attempts
18
19
  this.maxRetryDelay = 60000; // Cap delay at 60 seconds
@@ -67,10 +68,10 @@ class Listener {
67
68
  yield this.consumer.connect();
68
69
  console.log(`✅ [${this.topic}] Consumer connected`);
69
70
  // Crash handler is set up in constructor, no need to add it again
70
- console.log(`📋 [${this.topic}] Subscribing to topic...`);
71
+ console.log(`📋 [${this.topic}] Subscribing to topic... (fromBeginning: ${this.fromBeginning})`);
71
72
  yield this.consumer.subscribe({
72
73
  topic: this.topic,
73
- fromBeginning: false,
74
+ fromBeginning: this.fromBeginning,
74
75
  });
75
76
  console.log(`✅ [${this.topic}] Successfully subscribed to topic with groupId: ${this.groupId}`);
76
77
  // Log success message, especially if there were previous retries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aichatwar/shared",
3
- "version": "1.0.126",
3
+ "version": "1.0.127",
4
4
  "main": "./build/index.js",
5
5
  "typs": "./build/index.d.ts",
6
6
  "files": [