@t4h.framework/dev 0.0.0-experimental-20261005174326 → 0.0.0-experimental-20261006120135
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/CHANGELOG.md +22 -4
- package/README.md +38 -12
- package/dist/AppProcess.d.ts +4 -1
- package/dist/AppProcess.js +8 -2
- package/dist/AppProcess.js.map +1 -1
- package/dist/Server.d.ts +1 -0
- package/dist/Server.js +15 -0
- package/dist/Server.js.map +1 -1
- package/dist/constants/server.d.ts +5 -1
- package/dist/constants/server.js +5 -1
- package/dist/constants/server.js.map +1 -1
- package/dist/models/FrameworkConfig.d.ts +11 -0
- package/dist/models/FrameworkConfig.js +1 -0
- package/dist/models/FrameworkConfig.js.map +1 -1
- package/dist/models/LocalWorkflowRunJobExecutor.d.ts +10 -0
- package/dist/models/LocalWorkflowRunJobExecutor.js +23 -0
- package/dist/models/LocalWorkflowRunJobExecutor.js.map +1 -0
- package/dist/models/WorkflowRunJob.d.ts +91 -0
- package/dist/models/WorkflowRunJob.js +2 -0
- package/dist/models/WorkflowRunJob.js.map +1 -0
- package/dist/models/WorkflowWorkerPool.d.ts +39 -0
- package/dist/models/WorkflowWorkerPool.js +154 -0
- package/dist/models/WorkflowWorkerPool.js.map +1 -0
- package/dist/models/claims/DevCacheClaim.d.ts +2 -1
- package/dist/models/claims/DevCacheClaim.js +17 -6
- package/dist/models/claims/DevCacheClaim.js.map +1 -1
- package/dist/models/claims/DevORMClaim.js +6 -1
- package/dist/models/claims/DevORMClaim.js.map +1 -1
- package/dist/services/CallbackToken.service.d.ts +4 -1
- package/dist/services/CallbackToken.service.js +10 -3
- package/dist/services/CallbackToken.service.js.map +1 -1
- package/dist/services/Database.service.d.ts +8 -0
- package/dist/services/Database.service.js +18 -3
- package/dist/services/Database.service.js.map +1 -1
- package/dist/services/WorkflowRunAsyncActivityFacade.service.d.ts +2 -0
- package/dist/services/WorkflowRunAsyncActivityFacade.service.js +6 -0
- package/dist/services/WorkflowRunAsyncActivityFacade.service.js.map +1 -1
- package/dist/services/WorkflowRunEvents.service.d.ts +9 -0
- package/dist/services/WorkflowRunEvents.service.js +13 -2
- package/dist/services/WorkflowRunEvents.service.js.map +1 -1
- package/dist/services/WorkflowRunFacade.service.d.ts +1 -0
- package/dist/services/WorkflowRunFacade.service.js +3 -0
- package/dist/services/WorkflowRunFacade.service.js.map +1 -1
- package/dist/services/WorkflowRunScheduler.service.d.ts +52 -0
- package/dist/services/WorkflowRunScheduler.service.js +188 -0
- package/dist/services/WorkflowRunScheduler.service.js.map +1 -0
- package/dist/tools/run-workflow-run-job.d.ts +3 -0
- package/dist/tools/run-workflow-run-job.js +25 -0
- package/dist/tools/run-workflow-run-job.js.map +1 -0
- package/dist/transport/AppProcessJsonRpc.js +17 -4
- package/dist/transport/AppProcessJsonRpc.js.map +1 -1
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.d.ts +3 -5
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js +6 -10
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js.map +1 -1
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.d.ts +3 -9
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js +7 -39
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js.map +1 -1
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.d.ts +3 -5
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js +11 -15
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js.map +1 -1
- package/dist/use-cases/NextTickWorkflowRun.usecase.d.ts +4 -1
- package/dist/use-cases/NextTickWorkflowRun.usecase.js +16 -2
- package/dist/use-cases/NextTickWorkflowRun.usecase.js.map +1 -1
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.d.ts +10 -2
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.js +35 -5
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.js.map +1 -1
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.d.ts +14 -0
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.js +55 -0
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.js.map +1 -0
- package/dist/workers/app-process.d.ts +8 -0
- package/dist/workers/app-process.js +95 -12
- package/dist/workers/app-process.js.map +1 -1
- package/dist/workers/workflow-worker.d.ts +1 -0
- package/dist/workers/workflow-worker.js +54 -0
- package/dist/workers/workflow-worker.js.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
# @t4h.framework/dev
|
|
2
2
|
|
|
3
|
-
## 0.0.0-experimental-
|
|
3
|
+
## 0.0.0-experimental-20261006120135
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#207](https://github.com/tech4humans-brasil/framework/pull/207) [`92db468`](https://github.com/tech4humans-brasil/framework/commit/92db468f819d3c7d01884526598acd5fbef9b4ef) Thanks [@tony-tsx](https://github.com/tony-tsx)! - Workflows run asynchronously on a pool of worker threads. Starting a run,
|
|
8
|
+
delivering a callback, advancing an activity, a timeout and the settlement of a
|
|
9
|
+
parent run only queue work; a scheduler runs it with at most one step per run
|
|
10
|
+
at a time, keeps each run on the worker that started it and serves callbacks
|
|
11
|
+
ahead of background work. `advance` and callbacks still return the status of
|
|
12
|
+
the activity, but no longer wait for the rest of the workflow.
|
|
13
|
+
|
|
14
|
+
The pool defaults to the available CPUs minus one, 4 jobs per worker, and is set
|
|
15
|
+
with `runtime: { workers, concurrency }` in `framework.config.ts` (`workers: 0`
|
|
16
|
+
keeps everything on the app thread). The runtime database moves to a temporary
|
|
17
|
+
SQLite file in WAL mode shared by the workers, and the dev `CacheClaim` is
|
|
18
|
+
stored there so every worker sees the same cache. A worker that dies rejects
|
|
19
|
+
the runs it held and is replaced.
|
|
20
|
+
|
|
21
|
+
## 0.22.4
|
|
22
|
+
|
|
23
|
+
## 0.22.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
6
26
|
|
|
7
|
-
- [#201](https://github.com/tech4humans-brasil/framework/pull/201) [`
|
|
27
|
+
- [#201](https://github.com/tech4humans-brasil/framework/pull/201) [`374e2d7`](https://github.com/tech4humans-brasil/framework/commit/374e2d759ac1fda954981545a791652dede445ae) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Registers `MapCollection` as the `orm:map-collection` JSON codec kind, and
|
|
8
28
|
`DevORMClaim` reads several rows in one query with `getSnapshots`.
|
|
9
|
-
- Updated dependencies [[`f009132`](https://github.com/tech4humans-brasil/framework/commit/f009132dde28a7e6b36c754625d434b735b0fdda)]:
|
|
10
|
-
- @t4h.framework/orm@0.0.0-experimental-20261005174326
|
|
11
29
|
|
|
12
30
|
## 0.22.2
|
|
13
31
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Local development runtime for [T4H Framework](https://github.com/tech4humans-bra
|
|
|
7
7
|
When you run `framework dev` (via `@t4h.framework/cli`), this package powers the experience behind the scenes:
|
|
8
8
|
|
|
9
9
|
1. **TypeScript watch** — compiles your app on every change.
|
|
10
|
-
2. **App process** — forks a child Node process that loads your compiled `App
|
|
10
|
+
2. **App process** — forks a child Node process that loads your compiled `App`, queues every workflow step and runs them on a pool of worker threads sized to the machine (see [Execution](#execution)).
|
|
11
11
|
3. **HTTP server** — a [Hono](https://hono.dev) app that exposes your workflows (create runs, advance pending activities), enforces the workflow authorization and adds `/_dev` routes for tooling.
|
|
12
12
|
4. **Vite** — a Vite dev server in middleware mode serves the built-in panel and anything else that is not an API route.
|
|
13
13
|
5. **Dev claims** — provides local implementations for ORM, HTTP, file system, cache, SMTP, and more.
|
|
@@ -23,16 +23,20 @@ flowchart TB
|
|
|
23
23
|
HTTP --> Auth
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
subgraph child ["Child process (app-process
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
subgraph child ["Child process (app-process)"]
|
|
27
|
+
Queue["Scheduler queue + timers"]
|
|
28
|
+
DB[("Runtime SQLite (temp file, WAL)")]
|
|
29
|
+
subgraph workers ["Worker threads"]
|
|
30
|
+
App["User App + dev claims"]
|
|
31
|
+
end
|
|
32
|
+
Queue -->|"jobs"| App
|
|
33
|
+
App -->|"child runs, timeouts, events"| Queue
|
|
34
|
+
Queue --- DB
|
|
35
|
+
App --- DB
|
|
32
36
|
end
|
|
33
37
|
|
|
34
|
-
Fork -->
|
|
35
|
-
HTTP <-->|"IPC / JSON-RPC"|
|
|
38
|
+
Fork --> Queue
|
|
39
|
+
HTTP <-->|"IPC / JSON-RPC"| Queue
|
|
36
40
|
```
|
|
37
41
|
|
|
38
42
|
## Installation
|
|
@@ -162,11 +166,33 @@ Every `/projects` route requires an authorization: the workflow `authorization`
|
|
|
162
166
|
|
|
163
167
|
Everything else is handed to Vite, which serves the panel that ships with this package: open the base URL to browse the workflows and start runs from their schema, follow runs live with the execution trace of each one (activities as a waterfall, child runs nested, input, output, duration, logs, the activity that failed) and advance waiting activities. Plugins from the project's `vite.config.*` (or `vite.plugins`) are served by the same Vite.
|
|
164
168
|
|
|
169
|
+
## Execution
|
|
170
|
+
|
|
171
|
+
Starting a run, delivering a callback or advancing an activity only queues work; the app process answers right away and a scheduler hands each step (a _job_) to a pool of `worker_threads`. Every worker loads its own copy of your `App`, so a CPU-heavy activity blocks only its worker — the HTTP API, the panel and the other runs keep going. No message broker is involved: the queue lives in the app process, like the rest of the dev state.
|
|
172
|
+
|
|
173
|
+
- **Capacity** — `workers` threads (default: available CPUs − 1) each run up to `concurrency` jobs at once (default: 4). Extra work waits in the queue.
|
|
174
|
+
- **Order** — a run never has two jobs in flight, and all jobs of a run go to the worker that started it. Callbacks and advances jump ahead of background work.
|
|
175
|
+
- **Responses** — `advance` and callbacks still run the activity's `advance` and return its status; the steps after it run in the background (follow them through `run:updated`).
|
|
176
|
+
- **Failures** — if a worker dies, its in-flight jobs fail, the runs it held are rejected (`The workflow worker running this run stopped`) and a new worker takes its place.
|
|
177
|
+
|
|
178
|
+
Tune it in `framework.config.ts`:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { defineConfig } from '@t4h.framework/dev/config'
|
|
182
|
+
|
|
183
|
+
export default defineConfig({
|
|
184
|
+
runtime: {
|
|
185
|
+
workers: 2, // 0 runs workflows on the app process thread
|
|
186
|
+
concurrency: 4,
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
165
191
|
## State
|
|
166
192
|
|
|
167
|
-
Workflow runs, activities, pending async activities and
|
|
193
|
+
Workflow runs, activities, pending async activities, logs and the cache live in a SQLite database (`node:sqlite`) in a temporary file the app process creates and removes on exit; the workers open the same file (WAL mode). With `workers: 0` it stays in memory. Every successful build forks a fresh process, so **a rebuild resets all runs, timers and pending activities**; the `manifest` SSE event tells a UI to reload. The queue is not durable either: nothing resumes across rebuilds, by design.
|
|
168
194
|
|
|
169
|
-
Sync activities run
|
|
195
|
+
Sync activities run inside the job of their run, `sleep` and other timeouts are timers in the app process that queue the run when they fire, and child workflows started with `startWorkflow` / `startWorkflowMany` run in parallel across the workers.
|
|
170
196
|
|
|
171
197
|
The ORM claim is the exception: its rows live in `db.sqlite` next to your `package.json` and survive rebuilds and restarts (add it to `.gitignore`). Delete the file to start over. The previous `db.json` is no longer read.
|
|
172
198
|
|
|
@@ -219,7 +245,7 @@ In production, claims are fulfilled by the runtime (database connections, real H
|
|
|
219
245
|
| `HttpClientRequestClaim` | Real HTTP via `undici` |
|
|
220
246
|
| `FileSystemClaim` | Local file system with dev binary codec |
|
|
221
247
|
| `SmtpSendEmailClaim` | Captures emails in memory (no delivery) |
|
|
222
|
-
| `CacheClaim` |
|
|
248
|
+
| `CacheClaim` | Runtime SQLite table shared by every worker (reset on rebuild) |
|
|
223
249
|
| `WorkflowClaim` | Runs workflows through the local workflow engine |
|
|
224
250
|
|
|
225
251
|
Import the full claim registry:
|
package/dist/AppProcess.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fork } from 'node:child_process';
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import type { App } from '@t4h.framework/core';
|
|
4
|
+
import type { FrameworkRuntimeConfig } from './models/FrameworkConfig.js';
|
|
4
5
|
export type AppManifest = ReturnType<App['toManifest']>;
|
|
5
6
|
export type AppProcessState = 'idle' | 'starting' | 'ready' | 'exited';
|
|
6
7
|
export declare class AppProcessNotReadyError extends Error {
|
|
@@ -15,6 +16,8 @@ export interface AppProcessOptions {
|
|
|
15
16
|
export interface AppProcessUpOptions {
|
|
16
17
|
/** Public origin of the HTTP server in front of this process; webhooks build callback URLs on it. */
|
|
17
18
|
serverUrl?: string;
|
|
19
|
+
/** How the app runs workflows; see `FrameworkConfig.runtime`. */
|
|
20
|
+
runtime?: FrameworkRuntimeConfig;
|
|
18
21
|
}
|
|
19
22
|
export declare class AppProcess extends EventEmitter {
|
|
20
23
|
private readonly workerPath;
|
|
@@ -30,7 +33,7 @@ export declare class AppProcess extends EventEmitter {
|
|
|
30
33
|
constructor({ workerPath, readyTimeoutInMs, killTimeoutInMs, fork: forkProcess, }?: AppProcessOptions);
|
|
31
34
|
get manifest(): AppManifest | null;
|
|
32
35
|
get state(): AppProcessState;
|
|
33
|
-
up(entrypoint: string, env: Record<string, string>, { serverUrl }?: AppProcessUpOptions): Promise<AppManifest>;
|
|
36
|
+
up(entrypoint: string, env: Record<string, string>, { serverUrl, runtime }?: AppProcessUpOptions): Promise<AppManifest>;
|
|
34
37
|
down(): Promise<void>;
|
|
35
38
|
private kill;
|
|
36
39
|
whenReady(): Promise<AppManifest>;
|
package/dist/AppProcess.js
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'node:events';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { styleText } from 'node:util';
|
|
5
5
|
import Type from 'typebox';
|
|
6
|
-
import { APP_KILL_TIMEOUT_IN_MS, APP_READY_TIMEOUT_IN_MS, SERVER_URL_ARG, WORKFLOW_RUN_EVENTS, } from './constants/server.js';
|
|
6
|
+
import { APP_KILL_TIMEOUT_IN_MS, APP_READY_TIMEOUT_IN_MS, RUNTIME_CONCURRENCY_ARG, RUNTIME_WORKERS_ARG, SERVER_URL_ARG, WORKFLOW_RUN_EVENTS, } from './constants/server.js';
|
|
7
7
|
import { JSONRPCClient } from './models/JSONRPCClient.js';
|
|
8
8
|
import { JSONRPCServer, JSONRPCServerMethod } from './models/JSONRPCServer.js';
|
|
9
9
|
export class AppProcessNotReadyError extends Error {
|
|
@@ -39,7 +39,7 @@ export class AppProcess extends EventEmitter {
|
|
|
39
39
|
get state() {
|
|
40
40
|
return this.currentState;
|
|
41
41
|
}
|
|
42
|
-
async up(entrypoint, env, { serverUrl } = {}) {
|
|
42
|
+
async up(entrypoint, env, { serverUrl, runtime } = {}) {
|
|
43
43
|
const previous = this.child;
|
|
44
44
|
this.child = null;
|
|
45
45
|
this.client?.rejectPending(new AppProcessNotReadyError('App process is restarting'));
|
|
@@ -51,6 +51,12 @@ export class AppProcess extends EventEmitter {
|
|
|
51
51
|
const child = this.forkProcess(this.workerPath, [
|
|
52
52
|
entrypoint,
|
|
53
53
|
...(serverUrl ? [`${SERVER_URL_ARG}${serverUrl}`] : []),
|
|
54
|
+
...(runtime?.workers !== undefined
|
|
55
|
+
? [`${RUNTIME_WORKERS_ARG}${runtime.workers}`]
|
|
56
|
+
: []),
|
|
57
|
+
...(runtime?.concurrency !== undefined
|
|
58
|
+
? [`${RUNTIME_CONCURRENCY_ARG}${runtime.concurrency}`]
|
|
59
|
+
: []),
|
|
54
60
|
...Object.entries(env).map(([name, value]) => `${name}=${value}`),
|
|
55
61
|
], { stdio: ['ignore', 'inherit', 'inherit', 'ipc'] });
|
|
56
62
|
const client = new JSONRPCClient(message => {
|
package/dist/AppProcess.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProcess.js","sourceRoot":"","sources":["../src/AppProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAA;AAE1B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"AppProcess.js","sourceRoot":"","sources":["../src/AppProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAA;AAE1B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAM9E,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvB,IAAI,GAAG,yBAAyB,CAAA;CAC1D;AAgBD,MAAM,OAAO,UAAW,SAAQ,YAAY;IACzB,UAAU,CAAQ;IAClB,gBAAgB,CAAQ;IACxB,eAAe,CAAQ;IACvB,WAAW,CAAa;IACxB,MAAM,CAAe;IAE9B,KAAK,GAAwB,IAAI,CAAA;IACjC,MAAM,GAAyB,IAAI,CAAA;IACnC,KAAK,GAA6C,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U,MAAc,EAAE,GAAG,MAAa;QACzD,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QAEtB,IAAI,CAAC,IAAI,CAAC,MAAM;YACd,MAAM,IAAI,uBAAuB,CAAC,4BAA4B,CAAC,CAAA;QAEjE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAA;IAC5C,CAAC;IAEO,UAAU,CAAC,QAAqB;QACtC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAA;QAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAA;QAE3B,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;QAE7B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,CAAC;IAEO,MAAM,CAAC,KAAmB,EAAE,IAAmB;QACrD,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK;YAAE,OAAM;QAEhC,MAAM,KAAK,GAAG,IAAI,uBAAuB,CACvC,gCAAgC,IAAI,EAAE,CACvC,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAA;QAE5B,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAElB,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;QAEzB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzB,CAAC;CACF"}
|
package/dist/Server.d.ts
CHANGED
package/dist/Server.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createApp } from './http/create-app.js';
|
|
|
11
11
|
import { WorkflowAuthorizationMissingError } from './models/WorkflowAuthorizationMissingError.js';
|
|
12
12
|
import { findFreePort } from './tools/find-free-port.js';
|
|
13
13
|
import { formatRoutes } from './tools/format-routes.js';
|
|
14
|
+
import { loadFrameworkConfig } from './tools/load-framework-config.js';
|
|
14
15
|
import { mkdirOutDirProjectFromTsConfigPathAndJsonPackagePath } from './tools/mkdir-out-dir-project-from-ts-config-path-and-json-package-path.js';
|
|
15
16
|
import { resolvePackageJsonPath } from './tools/resolve-package-json-path.js';
|
|
16
17
|
import { resolveTsconfigFromPackageJsonPath } from './tools/resolve-tsconfig-path-from-package-json-path.js';
|
|
@@ -18,6 +19,17 @@ import { tsBuildWatch } from './tools/ts-build-watch.js';
|
|
|
18
19
|
function isApiPath(pathname) {
|
|
19
20
|
return [PROJECTS_ROUTES_PREFIX, DEV_ROUTES_PREFIX].some(prefix => pathname === prefix || pathname.startsWith(`${prefix}/`));
|
|
20
21
|
}
|
|
22
|
+
function toRuntimeConfig(runtime) {
|
|
23
|
+
if (!runtime)
|
|
24
|
+
return undefined;
|
|
25
|
+
const { workers, concurrency } = runtime;
|
|
26
|
+
if (workers !== undefined && !(Number.isInteger(workers) && workers >= 0))
|
|
27
|
+
throw new Error(`framework.config runtime.workers must be an integer >= 0, got ${workers}`);
|
|
28
|
+
if (concurrency !== undefined &&
|
|
29
|
+
!(Number.isInteger(concurrency) && concurrency >= 1))
|
|
30
|
+
throw new Error(`framework.config runtime.concurrency must be an integer >= 1, got ${concurrency}`);
|
|
31
|
+
return { workers, concurrency };
|
|
32
|
+
}
|
|
21
33
|
function notFound(res) {
|
|
22
34
|
res.statusCode = 404;
|
|
23
35
|
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
|
@@ -34,6 +46,7 @@ export class Server extends EventEmitter {
|
|
|
34
46
|
currentAddress = null;
|
|
35
47
|
packageJsonPath = null;
|
|
36
48
|
outDir = null;
|
|
49
|
+
runtime = undefined;
|
|
37
50
|
constructor(options) {
|
|
38
51
|
super();
|
|
39
52
|
this.options = options;
|
|
@@ -63,6 +76,7 @@ export class Server extends EventEmitter {
|
|
|
63
76
|
const project = await mkdirOutDirProjectFromTsConfigPathAndJsonPackagePath(tsConfigPath, this.packageJsonPath);
|
|
64
77
|
this.outDir = project.outDir;
|
|
65
78
|
const projectDir = path.dirname(this.packageJsonPath);
|
|
79
|
+
this.runtime = toRuntimeConfig((await loadFrameworkConfig(projectDir)).runtime);
|
|
66
80
|
const app = createApp({
|
|
67
81
|
appProcess: this.appProcess,
|
|
68
82
|
events: this,
|
|
@@ -139,6 +153,7 @@ export class Server extends EventEmitter {
|
|
|
139
153
|
try {
|
|
140
154
|
manifest = await this.appProcess.up(entrypoint, this.options.env, {
|
|
141
155
|
serverUrl: this.currentAddress?.url,
|
|
156
|
+
runtime: this.runtime,
|
|
142
157
|
});
|
|
143
158
|
}
|
|
144
159
|
catch (error) {
|
package/dist/Server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAItD,OAAO,EAAE,UAAU,EAAoB,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAA;AA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GAAG,UAAU,EAAE,UAAU,EAAE,OAAO,EAAqB;QAE7D,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;QAE7C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAA;QAE3E,OAAO,YAAY,CAAC;YAClB,IAAI;YACJ,UAAU;YACV,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;YAC7D,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;SAC/D,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -10,4 +10,8 @@ export declare const PROJECTS_ROUTES_PREFIX = "/projects";
|
|
|
10
10
|
export declare const DEV_ROUTES_PREFIX = "/_dev";
|
|
11
11
|
export declare const SERVER_URL_ARG = "--server-url=";
|
|
12
12
|
export declare const WORKFLOW_RUN_EVENTS: readonly ["run:created", "run:updated"];
|
|
13
|
-
|
|
13
|
+
/** Jobs a single workflow worker (or the app thread, without workers) runs at once. */
|
|
14
|
+
export declare const WORKFLOW_RUN_JOB_CONCURRENCY = 4;
|
|
15
|
+
export declare const RUNTIME_WORKERS_ARG = "--runtime-workers=";
|
|
16
|
+
export declare const RUNTIME_CONCURRENCY_ARG = "--runtime-concurrency=";
|
|
17
|
+
export declare const WORKFLOW_WORKER_READY_TIMEOUT_IN_MS = 30000;
|
package/dist/constants/server.js
CHANGED
|
@@ -10,5 +10,9 @@ export const PROJECTS_ROUTES_PREFIX = '/projects';
|
|
|
10
10
|
export const DEV_ROUTES_PREFIX = '/_dev';
|
|
11
11
|
export const SERVER_URL_ARG = '--server-url=';
|
|
12
12
|
export const WORKFLOW_RUN_EVENTS = ['run:created', 'run:updated'];
|
|
13
|
-
|
|
13
|
+
/** Jobs a single workflow worker (or the app thread, without workers) runs at once. */
|
|
14
|
+
export const WORKFLOW_RUN_JOB_CONCURRENCY = 4;
|
|
15
|
+
export const RUNTIME_WORKERS_ARG = '--runtime-workers=';
|
|
16
|
+
export const RUNTIME_CONCURRENCY_ARG = '--runtime-concurrency=';
|
|
17
|
+
export const WORKFLOW_WORKER_READY_TIMEOUT_IN_MS = 30_000;
|
|
14
18
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/constants/server.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAA;AAEvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,GAAG,IAAI,CAAA;AAElD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,GAAG,IAAI,CAAA;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAE3C,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAA;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAA;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAA;AAE7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,aAAa,CAAU,CAAA;AAE1E,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/constants/server.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEhC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAA;AAEvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,GAAG,IAAI,CAAA;AAElD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,GAAG,IAAI,CAAA;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAE3C,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAA;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAA;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAA;AAE7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,aAAa,CAAU,CAAA;AAE1E,uFAAuF;AACvF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAE7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAA;AAE/D,MAAM,CAAC,MAAM,mCAAmC,GAAG,MAAM,CAAA"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
export type FrameworkBuildConfig = {
|
|
2
2
|
assets?: readonly string[];
|
|
3
3
|
};
|
|
4
|
+
export type FrameworkRuntimeConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Worker threads that run workflows in `t4h dev`. Defaults to the available
|
|
7
|
+
* CPUs minus one; `0` runs them on the app thread.
|
|
8
|
+
*/
|
|
9
|
+
workers?: number;
|
|
10
|
+
/** Jobs each worker (or the app thread) runs at once. Defaults to 4. */
|
|
11
|
+
concurrency?: number;
|
|
12
|
+
};
|
|
4
13
|
export type FrameworkConfig = {
|
|
5
14
|
build?: FrameworkBuildConfig;
|
|
15
|
+
runtime?: FrameworkRuntimeConfig;
|
|
6
16
|
};
|
|
7
17
|
/**
|
|
8
18
|
* Identity helper that types a `framework.config.ts` default export.
|
|
@@ -13,6 +23,7 @@ export type FrameworkConfig = {
|
|
|
13
23
|
*
|
|
14
24
|
* export default defineConfig({
|
|
15
25
|
* build: { assets: ['assets/**'] },
|
|
26
|
+
* runtime: { workers: 2, concurrency: 4 },
|
|
16
27
|
* })
|
|
17
28
|
*/
|
|
18
29
|
export declare function defineConfig(config: FrameworkConfig): FrameworkConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameworkConfig.js","sourceRoot":"","sources":["../../src/models/FrameworkConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FrameworkConfig.js","sourceRoot":"","sources":["../../src/models/FrameworkConfig.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB;IAClD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WorkflowRunJob } from './WorkflowRunJob.js';
|
|
2
|
+
import type { WorkflowRunJobExecutor } from '../services/WorkflowRunScheduler.service.js';
|
|
3
|
+
/** Runs jobs on the current thread, one lane, `concurrency` at a time. */
|
|
4
|
+
export declare class LocalWorkflowRunJobExecutor implements WorkflowRunJobExecutor {
|
|
5
|
+
readonly concurrency: number;
|
|
6
|
+
readonly lanes = 1;
|
|
7
|
+
constructor(concurrency?: number);
|
|
8
|
+
execute(_lane: number, job: WorkflowRunJob): Promise<unknown>;
|
|
9
|
+
broadcast(job: WorkflowRunJob): Promise<unknown[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { setImmediate } from 'node:timers/promises';
|
|
2
|
+
import { container } from 'pleroma';
|
|
3
|
+
import { WORKFLOW_RUN_JOB_CONCURRENCY } from '../constants/server.js';
|
|
4
|
+
import { WorkflowRunLockService } from '../services/WorkflowRunLock.service.js';
|
|
5
|
+
import { runWorkflowRunJob } from '../tools/run-workflow-run-job.js';
|
|
6
|
+
/** Runs jobs on the current thread, one lane, `concurrency` at a time. */
|
|
7
|
+
export class LocalWorkflowRunJobExecutor {
|
|
8
|
+
concurrency;
|
|
9
|
+
lanes = 1;
|
|
10
|
+
constructor(concurrency = WORKFLOW_RUN_JOB_CONCURRENCY) {
|
|
11
|
+
this.concurrency = concurrency;
|
|
12
|
+
}
|
|
13
|
+
execute(_lane, job) {
|
|
14
|
+
return container.resolve(WorkflowRunLockService).detach(async () => {
|
|
15
|
+
await setImmediate();
|
|
16
|
+
return runWorkflowRunJob(job);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async broadcast(job) {
|
|
20
|
+
return [await this.execute(0, job)];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=LocalWorkflowRunJobExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalWorkflowRunJobExecutor.js","sourceRoot":"","sources":["../../src/models/LocalWorkflowRunJobExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEpE,0EAA0E;AAC1E,MAAM,OAAO,2BAA2B;IAGV;IAFZ,KAAK,GAAG,CAAC,CAAA;IAEzB,YAA4B,cAAc,4BAA4B;QAA1C,gBAAW,GAAX,WAAW,CAA+B;IAAG,CAAC;IAEnE,OAAO,CAAC,KAAa,EAAE,GAAmB;QAC/C,OAAO,SAAS,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACjE,MAAM,YAAY,EAAE,CAAA;YAEpB,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC/B,CAAC,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,GAAmB;QACxC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { AsyncActivityCallback } from '@t4h.framework/core';
|
|
2
|
+
/**
|
|
3
|
+
* Unit of work the scheduler hands to an executor. Jobs carrying a `runId`
|
|
4
|
+
* are serialized per run and pinned to the executor lane that first ran it,
|
|
5
|
+
* since activity constructors only live in the thread that pushed them.
|
|
6
|
+
*/
|
|
7
|
+
export type WorkflowRunJob = {
|
|
8
|
+
kind: 'run.tick';
|
|
9
|
+
runId: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'run.settle-parent';
|
|
12
|
+
runId: string;
|
|
13
|
+
childRunId: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'pending.execute';
|
|
16
|
+
runId: string;
|
|
17
|
+
pendingId: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'activity.advance';
|
|
20
|
+
runId?: string;
|
|
21
|
+
activityId: string;
|
|
22
|
+
payload: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'callback.create';
|
|
25
|
+
runId?: string;
|
|
26
|
+
activityId: string;
|
|
27
|
+
token: string;
|
|
28
|
+
request: AsyncActivityCallback.Delivery;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'event.deliver';
|
|
31
|
+
runId: string;
|
|
32
|
+
activityId: string;
|
|
33
|
+
pendingId: string;
|
|
34
|
+
delivery: AsyncActivityCallback.Delivery;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'event.correlate';
|
|
37
|
+
event: AsyncActivityCallback.Event;
|
|
38
|
+
};
|
|
39
|
+
export type WorkflowRunJobKind = WorkflowRunJob['kind'];
|
|
40
|
+
export interface SerializedJobError {
|
|
41
|
+
name: string;
|
|
42
|
+
message: string;
|
|
43
|
+
stack?: string;
|
|
44
|
+
code?: number;
|
|
45
|
+
data?: unknown;
|
|
46
|
+
}
|
|
47
|
+
/** Messages a workflow worker sends back to the coordinator thread. */
|
|
48
|
+
export type WorkflowWorkerMessage = {
|
|
49
|
+
type: 'ready';
|
|
50
|
+
} | {
|
|
51
|
+
type: 'boot-failed';
|
|
52
|
+
error: SerializedJobError;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'job:fulfilled';
|
|
55
|
+
id: number;
|
|
56
|
+
value: unknown;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'job:rejected';
|
|
59
|
+
id: number;
|
|
60
|
+
error: SerializedJobError;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'queue:enqueue';
|
|
63
|
+
job: WorkflowRunJob;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'timeout:schedule';
|
|
66
|
+
runId: string;
|
|
67
|
+
pendingId: string;
|
|
68
|
+
timeoutAt: number;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'timeout:cancel';
|
|
71
|
+
pendingId: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'events:run-created';
|
|
74
|
+
payload: unknown;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'events:run-updated';
|
|
77
|
+
runId: string;
|
|
78
|
+
};
|
|
79
|
+
/** Messages the coordinator thread sends to a workflow worker. */
|
|
80
|
+
export type WorkflowCoordinatorMessage = {
|
|
81
|
+
type: 'job';
|
|
82
|
+
id: number;
|
|
83
|
+
job: WorkflowRunJob;
|
|
84
|
+
};
|
|
85
|
+
export interface WorkflowWorkerData {
|
|
86
|
+
entrypoint: string;
|
|
87
|
+
env: [string, string][];
|
|
88
|
+
serverUrl: string | null;
|
|
89
|
+
databaseLocation: string;
|
|
90
|
+
callbackSecret: string;
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowRunJob.js","sourceRoot":"","sources":["../../src/models/WorkflowRunJob.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SerializedJobError, WorkflowRunJob, WorkflowWorkerData, WorkflowWorkerMessage } from './WorkflowRunJob.js';
|
|
2
|
+
import type { WorkflowRunJobExecutor } from '../services/WorkflowRunScheduler.service.js';
|
|
3
|
+
type WorkerSignal = Exclude<WorkflowWorkerMessage, {
|
|
4
|
+
type: 'ready' | 'boot-failed' | 'job:fulfilled' | 'job:rejected';
|
|
5
|
+
}>;
|
|
6
|
+
export interface WorkflowWorkerPoolOptions {
|
|
7
|
+
size: number;
|
|
8
|
+
concurrency: number;
|
|
9
|
+
workerData: WorkflowWorkerData;
|
|
10
|
+
/** Work a worker hands back to the coordinator (queue, timeouts, events). */
|
|
11
|
+
onSignal: (signal: WorkerSignal) => void;
|
|
12
|
+
/** A worker died; its replacement starts with an empty activity registry. */
|
|
13
|
+
onLaneLost: (lane: number, error: Error) => void;
|
|
14
|
+
workerPath?: string;
|
|
15
|
+
readyTimeoutInMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function toSerializedJobError(error: unknown): SerializedJobError;
|
|
18
|
+
export declare function fromSerializedJobError(error: SerializedJobError): Error;
|
|
19
|
+
/** Runs workflow jobs on `size` worker threads, each with its own app copy. */
|
|
20
|
+
export declare class WorkflowWorkerPool implements WorkflowRunJobExecutor {
|
|
21
|
+
private readonly options;
|
|
22
|
+
readonly lanes: number;
|
|
23
|
+
readonly concurrency: number;
|
|
24
|
+
private readonly workerPath;
|
|
25
|
+
private readonly readyTimeoutInMs;
|
|
26
|
+
private readonly slots;
|
|
27
|
+
private readonly booting;
|
|
28
|
+
private nextJobId;
|
|
29
|
+
private closing;
|
|
30
|
+
constructor(options: WorkflowWorkerPoolOptions);
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
execute(lane: number, job: WorkflowRunJob): Promise<unknown>;
|
|
33
|
+
broadcast(job: WorkflowRunJob): Promise<unknown[]>;
|
|
34
|
+
terminate(): Promise<void>;
|
|
35
|
+
private spawn;
|
|
36
|
+
private lose;
|
|
37
|
+
private failPending;
|
|
38
|
+
}
|
|
39
|
+
export {};
|