pulse-sdk 1.0.13 → 1.0.14

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.
@@ -1,7 +1,9 @@
1
1
  export declare class Producer {
2
2
  private client;
3
3
  private config;
4
+ private stream;
4
5
  constructor(host?: string, port?: number);
6
+ private initStream;
5
7
  private setupTopics;
6
8
  send(topic: string, payload: any): Promise<void>;
7
9
  streamSend(messages: Array<{
package/dist/producer.js CHANGED
@@ -11,6 +11,18 @@ class Producer {
11
11
  const address = `${h}:${p}`;
12
12
  this.client = (0, client_1.createClient)(address);
13
13
  this.setupTopics();
14
+ this.initStream();
15
+ }
16
+ initStream() {
17
+ this.stream = this.client.StreamPublish((err, summary) => {
18
+ if (err) {
19
+ console.error('StreamPublish ended with error:', err);
20
+ }
21
+ });
22
+ this.stream.on('error', (err) => {
23
+ console.error('StreamPublish stream error:', err);
24
+ // Simple reconnect attempt could be added here
25
+ });
14
26
  }
15
27
  setupTopics() {
16
28
  const topics = this.config.topics || [];
@@ -53,13 +65,11 @@ class Producer {
53
65
  payload: data,
54
66
  headers,
55
67
  };
56
- return new Promise((resolve, reject) => {
57
- this.client.Publish(req, (err, res) => {
58
- if (err)
59
- return reject(err);
60
- resolve();
61
- });
62
- });
68
+ // Write to the stream
69
+ // Note: This is now fire-and-forget for performance.
70
+ // We don't wait for server acknowledgement for every message.
71
+ this.stream.write(req);
72
+ return Promise.resolve();
63
73
  }
64
74
  async streamSend(messages) {
65
75
  return new Promise((resolve, reject) => {
@@ -100,6 +110,9 @@ class Producer {
100
110
  });
101
111
  }
102
112
  close() {
113
+ if (this.stream) {
114
+ this.stream.end();
115
+ }
103
116
  this.client.close();
104
117
  }
105
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulse-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Pulse SDK for Node.js/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",