@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 +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/skills/durable-setup/SKILL.md +7 -2
- package/skills/durable-workflows/SKILL.md +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -602,6 +602,18 @@ interface DurableModuleOptions {
|
|
|
602
602
|
* a driving instance's poll picks it up. Ignored (irrelevant) for a thin worker (no `store`).
|
|
603
603
|
*/
|
|
604
604
|
drive?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Whether this process CONSUMES from the broker. Defaults to `true`. Set `false` in a process that
|
|
607
|
+
* boots the module without being a worker — a CLI command, a REPL, a migration or seed script — so
|
|
608
|
+
* it doesn't compete with the real fleet: every transport that supports it (`BullMQTransport`) has
|
|
609
|
+
* its point-to-point consumers (step tasks, results, decisions, step events, start-run, run-request)
|
|
610
|
+
* parked via `deferConsumers()`, and no co-located/thin worker consumer starts. The process still
|
|
611
|
+
* dispatches and starts runs; the jobs stay on the queues for the fleet. Pair it with
|
|
612
|
+
* `drive: false` so it doesn't poll/recover runs either. To consume later in the same process, call
|
|
613
|
+
* `startConsumers()` on your transport. A transport without `deferConsumers()` (the SQL/SQS/in-process
|
|
614
|
+
* transports) keeps consuming — a warning says so.
|
|
615
|
+
*/
|
|
616
|
+
consumers?: boolean;
|
|
605
617
|
/** Max ms to wait for in-flight runs on shutdown before exiting. Defaults to 10000. Operator only. */
|
|
606
618
|
shutdownTimeoutMs?: number;
|
|
607
619
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -602,6 +602,18 @@ interface DurableModuleOptions {
|
|
|
602
602
|
* a driving instance's poll picks it up. Ignored (irrelevant) for a thin worker (no `store`).
|
|
603
603
|
*/
|
|
604
604
|
drive?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Whether this process CONSUMES from the broker. Defaults to `true`. Set `false` in a process that
|
|
607
|
+
* boots the module without being a worker — a CLI command, a REPL, a migration or seed script — so
|
|
608
|
+
* it doesn't compete with the real fleet: every transport that supports it (`BullMQTransport`) has
|
|
609
|
+
* its point-to-point consumers (step tasks, results, decisions, step events, start-run, run-request)
|
|
610
|
+
* parked via `deferConsumers()`, and no co-located/thin worker consumer starts. The process still
|
|
611
|
+
* dispatches and starts runs; the jobs stay on the queues for the fleet. Pair it with
|
|
612
|
+
* `drive: false` so it doesn't poll/recover runs either. To consume later in the same process, call
|
|
613
|
+
* `startConsumers()` on your transport. A transport without `deferConsumers()` (the SQL/SQS/in-process
|
|
614
|
+
* transports) keeps consuming — a warning says so.
|
|
615
|
+
*/
|
|
616
|
+
consumers?: boolean;
|
|
605
617
|
/** Max ms to wait for in-flight runs on shutdown before exiting. Defaults to 10000. Operator only. */
|
|
606
618
|
shutdownTimeoutMs?: number;
|
|
607
619
|
/**
|
package/dist/index.js
CHANGED
|
@@ -602,6 +602,7 @@ var ThinWorkerBootstrap = class {
|
|
|
602
602
|
const options = this.options;
|
|
603
603
|
const runtime = this.runtime;
|
|
604
604
|
if (runtime === null || !isPureThinWorker(options) || options.connection === void 0) return;
|
|
605
|
+
if (options.consumers === false) return;
|
|
605
606
|
const handle = await this.runRedisWorker({
|
|
606
607
|
runtime,
|
|
607
608
|
connection: options.connection,
|
|
@@ -980,6 +981,7 @@ var InAppWorkerBootstrap = class {
|
|
|
980
981
|
const options = this.options;
|
|
981
982
|
const runtime = this.runtime;
|
|
982
983
|
if (runtime === null || !isCoLocatedWorker(options) || options.connection === void 0) return;
|
|
984
|
+
if (options.consumers === false) return;
|
|
983
985
|
const handle = await this.runRedisWorker({
|
|
984
986
|
runtime,
|
|
985
987
|
connection: options.connection,
|
|
@@ -2536,6 +2538,15 @@ function scopedStore(store, options) {
|
|
|
2536
2538
|
});
|
|
2537
2539
|
}
|
|
2538
2540
|
__name(scopedStore, "scopedStore");
|
|
2541
|
+
function deferTransportConsumers(transport) {
|
|
2542
|
+
const deferrable = transport;
|
|
2543
|
+
if (typeof deferrable.deferConsumers === "function") {
|
|
2544
|
+
deferrable.deferConsumers();
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2547
|
+
console.warn(`[nestjs-durable] consumers: false \u2014 ${transport.constructor?.name ?? "this transport"} cannot defer its consumers and will keep consuming in this process`);
|
|
2548
|
+
}
|
|
2549
|
+
__name(deferTransportConsumers, "deferTransportConsumers");
|
|
2539
2550
|
function assertValidRole(options) {
|
|
2540
2551
|
const hasStore = options.store !== void 0;
|
|
2541
2552
|
const hasConnection = options.connection !== void 0;
|
|
@@ -2762,6 +2773,14 @@ var DurableModule = class _DurableModule {
|
|
|
2762
2773
|
const context = options.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
|
|
2763
2774
|
const runtime = accessor ? await resolveContextRuntime() : void 0;
|
|
2764
2775
|
const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
|
|
2776
|
+
if (options.consumers === false) {
|
|
2777
|
+
for (const t of [
|
|
2778
|
+
transport,
|
|
2779
|
+
...(options.transports ?? []).map((n) => n.transport)
|
|
2780
|
+
]) {
|
|
2781
|
+
if (t) deferTransportConsumers(t);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2765
2784
|
const engine = new WorkflowEngine6({
|
|
2766
2785
|
store,
|
|
2767
2786
|
transport: transport ?? void 0,
|