@dudousxd/nestjs-durable-core 0.44.1 → 0.45.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/dist/index.d.cts CHANGED
@@ -840,6 +840,13 @@ interface Transport {
840
840
  onResult(handler: (result: StepResult) => Promise<void>): void;
841
841
  /** worker → engine: liveness signal for an in-flight long step. */
842
842
  onHeartbeat(handler: (beat: Heartbeat) => Promise<void>): void;
843
+ /**
844
+ * Partition this transport's queues/keys by `namespace` (matching the engine's store namespace), so
845
+ * multiple logical deployments can share one broker. Idempotent. An explicit namespace passed to the
846
+ * transport's constructor TAKES PRECEDENCE over this. No-op when `namespace === "default"`. Optional —
847
+ * transports that don't partition simply omit it.
848
+ */
849
+ useNamespace?(namespace: string): void;
843
850
  /** Release the transport's resources (broker workers, queues, connections) for a clean shutdown.
844
851
  * Optional — an in-process transport has nothing to close. Called on `onApplicationShutdown`
845
852
  * after the engine drains, so a deploy hands off instead of leaving the broker to time out. */
package/dist/index.d.ts CHANGED
@@ -840,6 +840,13 @@ interface Transport {
840
840
  onResult(handler: (result: StepResult) => Promise<void>): void;
841
841
  /** worker → engine: liveness signal for an in-flight long step. */
842
842
  onHeartbeat(handler: (beat: Heartbeat) => Promise<void>): void;
843
+ /**
844
+ * Partition this transport's queues/keys by `namespace` (matching the engine's store namespace), so
845
+ * multiple logical deployments can share one broker. Idempotent. An explicit namespace passed to the
846
+ * transport's constructor TAKES PRECEDENCE over this. No-op when `namespace === "default"`. Optional —
847
+ * transports that don't partition simply omit it.
848
+ */
849
+ useNamespace?(namespace: string): void;
843
850
  /** Release the transport's resources (broker workers, queues, connections) for a clean shutdown.
844
851
  * Optional — an in-process transport has nothing to close. Called on `onApplicationShutdown`
845
852
  * after the engine drains, so a deploy hands off instead of leaving the broker to time out. */
package/dist/index.js CHANGED
@@ -913,6 +913,17 @@ var TransportPool = class {
913
913
  ...groups
914
914
  ];
915
915
  }
916
+ /**
917
+ * Propagate the engine's `namespace` to every transport that partitions by it — so the same
918
+ * namespace that scopes the store also scopes each transport's queues/keys. A transport that
919
+ * doesn't partition (no `useNamespace`) is skipped. Idempotent; a transport given an explicit
920
+ * namespace at construction ignores this (see {@link Transport.useNamespace}).
921
+ */
922
+ useNamespace(namespace) {
923
+ for (const { transport } of this.transports) {
924
+ transport.useNamespace?.(namespace);
925
+ }
926
+ }
916
927
  /** Pinned `preferId` first, then the rest (failover order). */
917
928
  ordered(preferId) {
918
929
  if (!preferId) return this.transports;
@@ -1580,6 +1591,7 @@ var WorkflowEngine = class {
1580
1591
  this.admission.onFreed?.((queue) => this.wakeQueueWaiters(queue));
1581
1592
  this.instanceId = deps.instanceId ?? globalThis.crypto.randomUUID();
1582
1593
  this.namespace = deps.namespace ?? "default";
1594
+ this.pool.useNamespace(this.namespace);
1583
1595
  this.leaseMs = deps.leaseMs ?? 3e4;
1584
1596
  this.maxRecoveryAttempts = deps.maxRecoveryAttempts;
1585
1597
  this.remoteAdvanceSilenceMs = deps.remoteAdvanceSilenceMs;