@flowcore/data-pump 0.18.0 → 0.19.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.19.0](https://github.com/flowcore-io/data-pump/compare/v0.18.1...v0.19.0) (2026-03-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * stagger pulse emissions with random initial delay ([ee8e3cf](https://github.com/flowcore-io/data-pump/commit/ee8e3cf988bb9d71451daa46ca43c54b2a44e57e))
9
+
10
+ ## [0.18.1](https://github.com/flowcore-io/data-pump/compare/v0.18.0...v0.18.1) (2026-03-27)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * include error message in pulse emission warning log ([5019c70](https://github.com/flowcore-io/data-pump/commit/5019c70c40dc49320b4075ea7ee53eec853453e4))
16
+
3
17
  ## [0.18.0](https://github.com/flowcore-io/data-pump/compare/v0.17.0...v0.18.0) (2026-03-26)
4
18
 
5
19
 
@@ -23,11 +23,13 @@ export declare class PulseEmitter {
23
23
  private readonly options;
24
24
  private readonly getSnapshot;
25
25
  private interval;
26
+ private startTimeout;
26
27
  private readonly intervalMs;
27
28
  private readonly logger?;
28
29
  constructor(options: PulseEmitterOptions, getSnapshot: () => PulseSnapshot | null);
29
30
  start(): void;
30
31
  stop(): void;
32
+ private emitSafe;
31
33
  private emit;
32
34
  }
33
35
  //# sourceMappingURL=pulse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pulse.d.ts","sourceRoot":"","sources":["../../src/data-pump/pulse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGtE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,MAAM,CAAC,EAAE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AO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAP9B,OAAO,CAAC,QAAQ,CAA8C;IAC9D,OAAO,CAAC,YAAY,CAA6C;IACjE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAgB;gBAGrB,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,MAAM,aAAa,GAAG,IAAI;IAM1D,KAAK,IAAI,IAAI;IAYb,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,QAAQ;YAOF,IAAI;CA2BnB"}
@@ -20,6 +20,12 @@ export class PulseEmitter {
20
20
  writable: true,
21
21
  value: null
22
22
  });
23
+ Object.defineProperty(this, "startTimeout", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: null
28
+ });
23
29
  Object.defineProperty(this, "intervalMs", {
24
30
  enumerable: true,
25
31
  configurable: true,
@@ -36,20 +42,32 @@ export class PulseEmitter {
36
42
  this.logger = options.logger;
37
43
  }
38
44
  start() {
39
- if (this.interval)
45
+ if (this.interval || this.startTimeout)
40
46
  return;
41
- this.interval = setInterval(() => {
42
- this.emit().catch((err) => {
43
- this.logger?.warn?.("Pulse emission failed", { error: err instanceof Error ? err.message : String(err) });
44
- });
45
- }, this.intervalMs);
47
+ // Random initial delay to stagger pulses from multiple pumps
48
+ const initialDelay = Math.floor(Math.random() * this.intervalMs);
49
+ this.startTimeout = setTimeout(() => {
50
+ this.startTimeout = null;
51
+ this.emitSafe();
52
+ this.interval = setInterval(() => this.emitSafe(), this.intervalMs);
53
+ }, initialDelay);
46
54
  }
47
55
  stop() {
56
+ if (this.startTimeout) {
57
+ clearTimeout(this.startTimeout);
58
+ this.startTimeout = null;
59
+ }
48
60
  if (this.interval) {
49
61
  clearInterval(this.interval);
50
62
  this.interval = null;
51
63
  }
52
64
  }
65
+ emitSafe() {
66
+ this.emit().catch((err) => {
67
+ const msg = err instanceof Error ? err.message : String(err);
68
+ this.logger?.warn?.(`Pulse emission failed: ${msg}`);
69
+ });
70
+ }
53
71
  async emit() {
54
72
  const snapshot = this.getSnapshot();
55
73
  if (!snapshot)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/data-pump",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Flowcore Data Pump",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-data-pump#readme",
6
6
  "repository": {
@@ -23,11 +23,13 @@ export declare class PulseEmitter {
23
23
  private readonly options;
24
24
  private readonly getSnapshot;
25
25
  private interval;
26
+ private startTimeout;
26
27
  private readonly intervalMs;
27
28
  private readonly logger?;
28
29
  constructor(options: PulseEmitterOptions, getSnapshot: () => PulseSnapshot | null);
29
30
  start(): void;
30
31
  stop(): void;
32
+ private emitSafe;
31
33
  private emit;
32
34
  }
33
35
  //# sourceMappingURL=pulse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pulse.d.ts","sourceRoot":"","sources":["../../src/data-pump/pulse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGtE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,MAAM,CAAC,EAAE,cAAc,CAAA;CACx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AAG,SAAS,CAAA;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAP9B,OAAO,CAAC,QAAQ,CAA8C;IAC9D,OAAO,CAAC,YAAY,CAA6C;IACjE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAgB;gBAGrB,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,MAAM,aAAa,GAAG,IAAI;IAM1D,KAAK,IAAI,IAAI;IAYb,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,QAAQ;YAOF,IAAI;CA2BnB"}
@@ -23,6 +23,12 @@ class PulseEmitter {
23
23
  writable: true,
24
24
  value: null
25
25
  });
26
+ Object.defineProperty(this, "startTimeout", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: null
31
+ });
26
32
  Object.defineProperty(this, "intervalMs", {
27
33
  enumerable: true,
28
34
  configurable: true,
@@ -39,20 +45,32 @@ class PulseEmitter {
39
45
  this.logger = options.logger;
40
46
  }
41
47
  start() {
42
- if (this.interval)
48
+ if (this.interval || this.startTimeout)
43
49
  return;
44
- this.interval = setInterval(() => {
45
- this.emit().catch((err) => {
46
- this.logger?.warn?.("Pulse emission failed", { error: err instanceof Error ? err.message : String(err) });
47
- });
48
- }, this.intervalMs);
50
+ // Random initial delay to stagger pulses from multiple pumps
51
+ const initialDelay = Math.floor(Math.random() * this.intervalMs);
52
+ this.startTimeout = setTimeout(() => {
53
+ this.startTimeout = null;
54
+ this.emitSafe();
55
+ this.interval = setInterval(() => this.emitSafe(), this.intervalMs);
56
+ }, initialDelay);
49
57
  }
50
58
  stop() {
59
+ if (this.startTimeout) {
60
+ clearTimeout(this.startTimeout);
61
+ this.startTimeout = null;
62
+ }
51
63
  if (this.interval) {
52
64
  clearInterval(this.interval);
53
65
  this.interval = null;
54
66
  }
55
67
  }
68
+ emitSafe() {
69
+ this.emit().catch((err) => {
70
+ const msg = err instanceof Error ? err.message : String(err);
71
+ this.logger?.warn?.(`Pulse emission failed: ${msg}`);
72
+ });
73
+ }
56
74
  async emit() {
57
75
  const snapshot = this.getSnapshot();
58
76
  if (!snapshot)