@dudousxd/nestjs-durable 0.23.0 → 0.25.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.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StepError, WorkflowRef, SingletonConfig, WorkflowExecutor, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowEngine, EntityHandler, StepInvocation, WorkflowClass, WorkflowInputOf, StartOptions, RunResult } from '@dudousxd/nestjs-durable-core';
|
|
2
|
-
import { RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
2
|
+
import { ConcurrencyOption, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
3
3
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
4
4
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
5
5
|
|
|
@@ -193,6 +193,18 @@ interface DurableWorkerModuleOptions {
|
|
|
193
193
|
prefix?: string;
|
|
194
194
|
/** Stable id for this worker process in heartbeats/control. Defaults to a per-host/pid id. */
|
|
195
195
|
instanceId?: string;
|
|
196
|
+
/**
|
|
197
|
+
* How many tasks each group's consumer runs concurrently (BullMQ Worker concurrency). Defaults to 1.
|
|
198
|
+
* Applies to every group unless overridden per-group by {@link concurrencyByGroup}. Raise it so a
|
|
199
|
+
* fanned-out batch (e.g. the N remote steps of a `gather`) runs in parallel instead of serially.
|
|
200
|
+
*
|
|
201
|
+
* Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let each consumer self-tune its concurrency
|
|
202
|
+
* (latency gradient + RAM brake + backpressure) and publish a live status on its heartbeat.
|
|
203
|
+
*/
|
|
204
|
+
concurrency?: ConcurrencyOption;
|
|
205
|
+
/** Per-group concurrency override, keyed by group name. Falls back to {@link concurrency} (then 1).
|
|
206
|
+
* Each value may itself be `'adaptive'` / `{ mode:'adaptive', ... }`. */
|
|
207
|
+
concurrencyByGroup?: Record<string, ConcurrencyOption>;
|
|
196
208
|
}
|
|
197
209
|
interface DurableWorkerModuleAsyncOptions {
|
|
198
210
|
useFactory: (...args: never[]) => DurableWorkerModuleOptions | Promise<DurableWorkerModuleOptions>;
|
|
@@ -286,6 +298,15 @@ interface DurableInAppWorkerOptions {
|
|
|
286
298
|
prefix?: string;
|
|
287
299
|
/** Stable id for this worker process in heartbeats/control. Defaults to a per-host/pid id. */
|
|
288
300
|
instanceId?: string;
|
|
301
|
+
/**
|
|
302
|
+
* How many tasks the co-located worker runs concurrently from its group's queue (BullMQ Worker
|
|
303
|
+
* concurrency). Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote steps of a
|
|
304
|
+
* `gather`) runs in parallel. Per process; total parallelism is `concurrency × replicas`.
|
|
305
|
+
*
|
|
306
|
+
* Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let the worker self-tune its concurrency
|
|
307
|
+
* (latency gradient + RAM brake + backpressure) and publish a live status on its heartbeat.
|
|
308
|
+
*/
|
|
309
|
+
concurrency?: ConcurrencyOption;
|
|
289
310
|
}
|
|
290
311
|
/** The resolved {@link DurableInAppWorkerOptions} or `null` when the app didn't opt in. */
|
|
291
312
|
declare const IN_APP_WORKER_OPTIONS: unique symbol;
|
|
@@ -382,6 +403,12 @@ interface DurableModuleOptions {
|
|
|
382
403
|
* off in production and call the store adapter's `ensure*DurableSchema()` from a migration.
|
|
383
404
|
*/
|
|
384
405
|
autoSchema?: boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Worker-pool partition for this instance (forwarded to the engine). Default `'default'`. Set a
|
|
408
|
+
* distinct value to share ONE state store across non-interchangeable pools — e.g. a developer's
|
|
409
|
+
* local instance vs the deployed cluster. See `WorkflowEngineDeps.namespace`.
|
|
410
|
+
*/
|
|
411
|
+
namespace?: string;
|
|
385
412
|
/**
|
|
386
413
|
* Multi-instance recovery lease, in ms — how long an instance owns a run it picked up before
|
|
387
414
|
* another may take over. Defaults to 30000. Set above your longest synchronous run.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StepError, WorkflowRef, SingletonConfig, WorkflowExecutor, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowEngine, EntityHandler, StepInvocation, WorkflowClass, WorkflowInputOf, StartOptions, RunResult } from '@dudousxd/nestjs-durable-core';
|
|
2
|
-
import { RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
2
|
+
import { ConcurrencyOption, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
3
3
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
4
4
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
5
5
|
|
|
@@ -193,6 +193,18 @@ interface DurableWorkerModuleOptions {
|
|
|
193
193
|
prefix?: string;
|
|
194
194
|
/** Stable id for this worker process in heartbeats/control. Defaults to a per-host/pid id. */
|
|
195
195
|
instanceId?: string;
|
|
196
|
+
/**
|
|
197
|
+
* How many tasks each group's consumer runs concurrently (BullMQ Worker concurrency). Defaults to 1.
|
|
198
|
+
* Applies to every group unless overridden per-group by {@link concurrencyByGroup}. Raise it so a
|
|
199
|
+
* fanned-out batch (e.g. the N remote steps of a `gather`) runs in parallel instead of serially.
|
|
200
|
+
*
|
|
201
|
+
* Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let each consumer self-tune its concurrency
|
|
202
|
+
* (latency gradient + RAM brake + backpressure) and publish a live status on its heartbeat.
|
|
203
|
+
*/
|
|
204
|
+
concurrency?: ConcurrencyOption;
|
|
205
|
+
/** Per-group concurrency override, keyed by group name. Falls back to {@link concurrency} (then 1).
|
|
206
|
+
* Each value may itself be `'adaptive'` / `{ mode:'adaptive', ... }`. */
|
|
207
|
+
concurrencyByGroup?: Record<string, ConcurrencyOption>;
|
|
196
208
|
}
|
|
197
209
|
interface DurableWorkerModuleAsyncOptions {
|
|
198
210
|
useFactory: (...args: never[]) => DurableWorkerModuleOptions | Promise<DurableWorkerModuleOptions>;
|
|
@@ -286,6 +298,15 @@ interface DurableInAppWorkerOptions {
|
|
|
286
298
|
prefix?: string;
|
|
287
299
|
/** Stable id for this worker process in heartbeats/control. Defaults to a per-host/pid id. */
|
|
288
300
|
instanceId?: string;
|
|
301
|
+
/**
|
|
302
|
+
* How many tasks the co-located worker runs concurrently from its group's queue (BullMQ Worker
|
|
303
|
+
* concurrency). Defaults to 1. Raise it so a fanned-out batch (e.g. the N remote steps of a
|
|
304
|
+
* `gather`) runs in parallel. Per process; total parallelism is `concurrency × replicas`.
|
|
305
|
+
*
|
|
306
|
+
* Pass `'adaptive'` (or `{ mode:'adaptive', ... }`) to let the worker self-tune its concurrency
|
|
307
|
+
* (latency gradient + RAM brake + backpressure) and publish a live status on its heartbeat.
|
|
308
|
+
*/
|
|
309
|
+
concurrency?: ConcurrencyOption;
|
|
289
310
|
}
|
|
290
311
|
/** The resolved {@link DurableInAppWorkerOptions} or `null` when the app didn't opt in. */
|
|
291
312
|
declare const IN_APP_WORKER_OPTIONS: unique symbol;
|
|
@@ -382,6 +403,12 @@ interface DurableModuleOptions {
|
|
|
382
403
|
* off in production and call the store adapter's `ensure*DurableSchema()` from a migration.
|
|
383
404
|
*/
|
|
384
405
|
autoSchema?: boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Worker-pool partition for this instance (forwarded to the engine). Default `'default'`. Set a
|
|
408
|
+
* distinct value to share ONE state store across non-interchangeable pools — e.g. a developer's
|
|
409
|
+
* local instance vs the deployed cluster. See `WorkflowEngineDeps.namespace`.
|
|
410
|
+
*/
|
|
411
|
+
namespace?: string;
|
|
385
412
|
/**
|
|
386
413
|
* Multi-instance recovery lease, in ms — how long an instance owns a run it picked up before
|
|
387
414
|
* another may take over. Defaults to 30000. Set above your longest synchronous run.
|
package/dist/index.js
CHANGED
|
@@ -218,6 +218,9 @@ var ThinWorkerBootstrap = class {
|
|
|
218
218
|
} : {},
|
|
219
219
|
...this.options.instanceId !== void 0 ? {
|
|
220
220
|
instanceId: this.options.instanceId
|
|
221
|
+
} : {},
|
|
222
|
+
...(this.options.concurrencyByGroup?.[group] ?? this.options.concurrency) !== void 0 ? {
|
|
223
|
+
concurrency: this.options.concurrencyByGroup?.[group] ?? this.options.concurrency
|
|
221
224
|
} : {}
|
|
222
225
|
});
|
|
223
226
|
this.runners.push(handle);
|
|
@@ -508,6 +511,9 @@ var InAppWorkerBootstrap = class {
|
|
|
508
511
|
} : {},
|
|
509
512
|
...this.options.instanceId !== void 0 ? {
|
|
510
513
|
instanceId: this.options.instanceId
|
|
514
|
+
} : {},
|
|
515
|
+
...this.options.concurrency !== void 0 ? {
|
|
516
|
+
concurrency: this.options.concurrency
|
|
511
517
|
} : {}
|
|
512
518
|
});
|
|
513
519
|
this.runners.push(handle);
|
|
@@ -1130,6 +1136,7 @@ var DurableModule = class _DurableModule {
|
|
|
1130
1136
|
maxRecoveryAttempts: opts.maxRecoveryAttempts,
|
|
1131
1137
|
remoteAdvanceSilenceMs: opts.remoteAdvanceSilenceMs,
|
|
1132
1138
|
instanceId: opts.instanceId,
|
|
1139
|
+
namespace: opts.namespace,
|
|
1133
1140
|
webhookUrl: opts.webhookUrl,
|
|
1134
1141
|
traceparent: opts.traceparent,
|
|
1135
1142
|
context,
|