@dudousxd/nestjs-durable 0.48.0 → 0.48.1

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.cjs CHANGED
@@ -692,6 +692,7 @@ var ThinWorkerBootstrap = class {
692
692
  const options = this.options;
693
693
  const runtime = this.runtime;
694
694
  if (runtime === null || !isPureThinWorker(options) || options.connection === void 0) return;
695
+ if (options.consumers === false) return;
695
696
  const handle = await this.runRedisWorker({
696
697
  runtime,
697
698
  connection: options.connection,
@@ -1070,6 +1071,7 @@ var InAppWorkerBootstrap = class {
1070
1071
  const options = this.options;
1071
1072
  const runtime = this.runtime;
1072
1073
  if (runtime === null || !isCoLocatedWorker(options) || options.connection === void 0) return;
1074
+ if (options.consumers === false) return;
1073
1075
  const handle = await this.runRedisWorker({
1074
1076
  runtime,
1075
1077
  connection: options.connection,
@@ -2626,6 +2628,15 @@ function scopedStore(store, options) {
2626
2628
  });
2627
2629
  }
2628
2630
  __name(scopedStore, "scopedStore");
2631
+ function deferTransportConsumers(transport) {
2632
+ const deferrable = transport;
2633
+ if (typeof deferrable.deferConsumers === "function") {
2634
+ deferrable.deferConsumers();
2635
+ return;
2636
+ }
2637
+ console.warn(`[nestjs-durable] consumers: false \u2014 ${transport.constructor?.name ?? "this transport"} cannot defer its consumers and will keep consuming in this process`);
2638
+ }
2639
+ __name(deferTransportConsumers, "deferTransportConsumers");
2629
2640
  function assertValidRole(options) {
2630
2641
  const hasStore = options.store !== void 0;
2631
2642
  const hasConnection = options.connection !== void 0;
@@ -2852,6 +2863,14 @@ var DurableModule = class _DurableModule {
2852
2863
  const context = options.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
2853
2864
  const runtime = accessor ? await resolveContextRuntime() : void 0;
2854
2865
  const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
2866
+ if (options.consumers === false) {
2867
+ for (const t of [
2868
+ transport,
2869
+ ...(options.transports ?? []).map((n) => n.transport)
2870
+ ]) {
2871
+ if (t) deferTransportConsumers(t);
2872
+ }
2873
+ }
2855
2874
  const engine = new import_nestjs_durable_core16.WorkflowEngine({
2856
2875
  store,
2857
2876
  transport: transport ?? void 0,