@dudousxd/nestjs-durable 0.63.0 → 0.65.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 +820 -357
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -14
- package/dist/index.d.ts +213 -14
- package/dist/index.js +684 -223
- package/dist/index.js.map +1 -1
- package/dist/migrate-from-nestjs-workflows.cjs +8 -2
- package/dist/migrate-from-nestjs-workflows.cjs.map +1 -1
- package/dist/migrate-from-nestjs-workflows.js +8 -2
- package/dist/migrate-from-nestjs-workflows.js.map +1 -1
- package/package.json +4 -4
- package/skills/durable-setup/SKILL.md +5 -1
- package/skills/durable-signals-and-timers/SKILL.md +12 -3
|
@@ -149,11 +149,15 @@ import { DurableModule } from '@dudousxd/nestjs-durable';
|
|
|
149
149
|
|
|
150
150
|
@Module({
|
|
151
151
|
imports: [DurableModule.forRoot({ connection: 'redis://localhost:6379', partition: 'payments' })],
|
|
152
|
-
providers: [PaymentsWorker], // @Step handlers this worker serves
|
|
152
|
+
providers: [PaymentsWorker, CheckoutWorkflow], // @Step handlers and/or @Workflow bodies this worker serves (announced to the control plane; @Entity is refused on a tenant)
|
|
153
153
|
})
|
|
154
154
|
export class WorkerAppModule {}
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
A tenant also registers its `@Workflow` bodies (with their `@DeadLetter()` routes, served as
|
|
158
|
+
`<name>.dlq`) and `@StepInterceptor()` providers on its worker runtime; the control plane drives
|
|
159
|
+
them by name. Source: packages/nestjs/src/durable-worker.module.ts (`ThinWorkflowRegistrar`).
|
|
160
|
+
|
|
157
161
|
`partition` is an optional isolation suffix on this worker's queues — omit it for a single-tenant
|
|
158
162
|
deployment. An operator with no local body for a workflow dispatches to a live worker of the same
|
|
159
163
|
name automatically; there's no `groups`/`remoteByConvention` flag to opt into.
|
|
@@ -83,6 +83,10 @@ export class ApprovalController {
|
|
|
83
83
|
filtering; `workflows.publishEvent(name, payload)` fans out to every run whose `match` the payload
|
|
84
84
|
satisfies (and starts any `@OnDurableEvent` workflows whose `where` accepts the payload, with
|
|
85
85
|
`input(payload)` as the run's input when the entry maps it). Returns how many runs it touched.
|
|
86
|
+
On a tenant (`connection`, no `store`) the fan-out is scoped to the tenant's partition — it starts
|
|
87
|
+
the app's own subscribers and resumes the partition's waiting runs, never buffers, and does not
|
|
88
|
+
apply `debounce`/`batch` (a coalescing subscriber starts once per event with a warning). Source:
|
|
89
|
+
packages/nestjs/src/durable-start-client.ts (`publishEvent`).
|
|
86
90
|
|
|
87
91
|
```ts
|
|
88
92
|
const order = await ctx.waitForEvent<Order>('order.paid', { match: { orderId: id } });
|
|
@@ -131,7 +135,9 @@ const result = await wh.wait(); // resumes on t
|
|
|
131
135
|
### signalWithStart — the accumulator pattern
|
|
132
136
|
|
|
133
137
|
`signalWithStart` ensures a run exists, then delivers a signal race-free — one long-lived run per key
|
|
134
|
-
fed by many calls.
|
|
138
|
+
fed by many calls. On a tenant (`connection`, no `store`) it is a control-plane run request scoped
|
|
139
|
+
to the tenant's partition, and the signal is buffered only when the token contains the run id.
|
|
140
|
+
Source: packages/nestjs/src/durable-start-client.ts (`signalWithStart`).
|
|
135
141
|
|
|
136
142
|
```ts
|
|
137
143
|
await this.workflows.signalWithStart(
|
|
@@ -195,5 +201,8 @@ await this.workflows.signal(`approve:${order.id}`, body);
|
|
|
195
201
|
```
|
|
196
202
|
|
|
197
203
|
`signal(token, payload)` resolves only the run waiting on that exact token; a mismatched token is
|
|
198
|
-
buffered and the run never wakes
|
|
199
|
-
|
|
204
|
+
buffered and the run never wakes — except on a tenant (`connection`, no `store`), where the signal
|
|
205
|
+
is a control-plane run request scoped to the tenant's partition: an unmatched signal resolves `null`
|
|
206
|
+
and is never buffered. Source: packages/nestjs/src/workflow.service.ts (`signal`),
|
|
207
|
+
packages/nestjs/src/proxy-run-gateway.ts (`signal`), packages/nestjs/src/durable-start-client.ts
|
|
208
|
+
(`signal`), packages/core/src/workflow-ctx.ts (`waitForSignal`).
|