cross-tab-worker-databus 0.20.17 → 0.20.18

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.
@@ -1261,7 +1261,7 @@ var PersistenceRetryCancelledError = class extends Error {
1261
1261
  this.name = "PersistenceRetryCancelledError";
1262
1262
  }
1263
1263
  };
1264
- var CrossTabDataBus = class _CrossTabDataBus {
1264
+ var CrossTabDataBus = class {
1265
1265
  transport;
1266
1266
  cluster;
1267
1267
  // Map of topic → set of local subscribers.
@@ -1325,7 +1325,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1325
1325
  // stop to settle.
1326
1326
  pendingStop = null;
1327
1327
  // Minimum interval in ms between automatic recovery attempts.
1328
- static RECOVERY_COOLDOWN_MS = 1e3;
1328
+ recoveryCooldownMs;
1329
1329
  constructor(options) {
1330
1330
  const replay = options.replay;
1331
1331
  if (replay) {
@@ -1355,7 +1355,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
1355
1355
  if (!Number.isFinite(this.persistenceRetryBackoffMs) || this.persistenceRetryBackoffMs < 0) {
1356
1356
  throw new TypeError("replay.persistenceRetry.backoffMs must be a non-negative finite number.");
1357
1357
  }
1358
- const { autoStart, initialConfig, trace, transport, dedup, ...clusterOptions } = options;
1358
+ const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
1359
+ this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
1360
+ if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
1361
+ throw new TypeError("recovery.cooldownMs must be a positive finite number.");
1362
+ }
1359
1363
  this.now = dedup?.now ?? Date.now;
1360
1364
  this.replayHydration = this.hydrateReplay();
1361
1365
  this.transport = transport;
@@ -1911,7 +1915,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1911
1915
  }
1912
1916
  if (status === "error" && this.started && !this.stopping) {
1913
1917
  const now = this.now();
1914
- if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1918
+ if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
1915
1919
  this.lastRecoveryAt = now;
1916
1920
  const attempt = ++this.recoveryAttempt;
1917
1921
  this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
@@ -1919,7 +1923,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1919
1923
  if (this.stopping || !this.started || this.suspended) return;
1920
1924
  if (this.status !== "error") return;
1921
1925
  void this.reopenTransport(attempt);
1922
- }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1926
+ }, this.recoveryCooldownMs);
1923
1927
  }
1924
1928
  }
1925
1929
  this.invokeHandlers(this.statusHandlers, (handler) => handler(status));