@t4h.framework/dev 0.0.0-experimental-29d0277 → 0.0.0-experimental-20261009202408
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 -0
- package/README.md +19 -95
- package/dist/AppProcess.d.ts +2 -16
- package/dist/AppProcess.js +4 -31
- package/dist/AppProcess.js.map +1 -1
- package/dist/Server.d.ts +0 -5
- package/dist/Server.js +0 -15
- package/dist/Server.js.map +1 -1
- package/dist/constants/server.d.ts +1 -14
- package/dist/constants/server.js +1 -14
- package/dist/constants/server.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/orm.js +1 -12
- package/dist/integrations/orm.js.map +1 -1
- package/dist/models/FrameworkConfig.d.ts +0 -20
- package/dist/models/FrameworkConfig.js +0 -2
- package/dist/models/FrameworkConfig.js.map +1 -1
- package/dist/models/claims/DevCacheClaim.d.ts +1 -2
- package/dist/models/claims/DevCacheClaim.js +6 -17
- package/dist/models/claims/DevCacheClaim.js.map +1 -1
- package/dist/models/claims/DevORMClaim.d.ts +8 -5
- package/dist/models/claims/DevORMClaim.js +55 -22
- package/dist/models/claims/DevORMClaim.js.map +1 -1
- package/dist/models/claims/DevWorkflowClaim.d.ts +1 -1
- package/dist/models/claims/DevWorkflowClaim.js +3 -2
- package/dist/models/claims/DevWorkflowClaim.js.map +1 -1
- package/dist/services/CallbackToken.service.d.ts +1 -4
- package/dist/services/CallbackToken.service.js +3 -10
- package/dist/services/CallbackToken.service.js.map +1 -1
- package/dist/services/Database.service.d.ts +0 -8
- package/dist/services/Database.service.js +3 -18
- package/dist/services/Database.service.js.map +1 -1
- package/dist/services/WorkflowRunAsyncActivityFacade.service.d.ts +0 -2
- package/dist/services/WorkflowRunAsyncActivityFacade.service.js +0 -6
- package/dist/services/WorkflowRunAsyncActivityFacade.service.js.map +1 -1
- package/dist/services/WorkflowRunEvents.service.d.ts +0 -9
- package/dist/services/WorkflowRunEvents.service.js +2 -13
- package/dist/services/WorkflowRunEvents.service.js.map +1 -1
- package/dist/services/WorkflowRunFacade.service.d.ts +0 -1
- package/dist/services/WorkflowRunFacade.service.js +0 -3
- package/dist/services/WorkflowRunFacade.service.js.map +1 -1
- package/dist/transport/AppProcessJsonRpc.js +4 -17
- package/dist/transport/AppProcessJsonRpc.js.map +1 -1
- package/dist/use-cases/BuildWorkflowRunActivityHistory.usecase.js +1 -7
- package/dist/use-cases/BuildWorkflowRunActivityHistory.usecase.js.map +1 -1
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.d.ts +5 -3
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js +10 -6
- package/dist/use-cases/CreateWorkflowRunAsyncActivity.usecase.js.map +1 -1
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.d.ts +9 -3
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js +39 -7
- package/dist/use-cases/EnqueueWorkflowRunNextTick.usecase.js.map +1 -1
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.d.ts +5 -5
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js +15 -29
- package/dist/use-cases/ExecuteWorkflowRunAsyncActivity.usecase.js.map +1 -1
- package/dist/use-cases/NextTickWorkflowRun.usecase.d.ts +1 -6
- package/dist/use-cases/NextTickWorkflowRun.usecase.js +3 -54
- package/dist/use-cases/NextTickWorkflowRun.usecase.js.map +1 -1
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.d.ts +2 -10
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.js +5 -35
- package/dist/use-cases/ReceiveWorkflowEvent.usecase.js.map +1 -1
- package/dist/workers/app-process.d.ts +0 -8
- package/dist/workers/app-process.js +14 -114
- package/dist/workers/app-process.js.map +1 -1
- package/package.json +24 -26
- package/LICENSE +0 -21
- package/dist/HeadlessApp.d.ts +0 -65
- package/dist/HeadlessApp.js +0 -166
- package/dist/HeadlessApp.js.map +0 -1
- package/dist/models/DevORMStore.d.ts +0 -18
- package/dist/models/DevORMStore.js +0 -7
- package/dist/models/DevORMStore.js.map +0 -1
- package/dist/models/LocalWorkflowRunJobExecutor.d.ts +0 -10
- package/dist/models/LocalWorkflowRunJobExecutor.js +0 -23
- package/dist/models/LocalWorkflowRunJobExecutor.js.map +0 -1
- package/dist/models/PostgresDevORMStore.d.ts +0 -23
- package/dist/models/PostgresDevORMStore.js +0 -94
- package/dist/models/PostgresDevORMStore.js.map +0 -1
- package/dist/models/RuntimeControlServer.d.ts +0 -32
- package/dist/models/RuntimeControlServer.js +0 -75
- package/dist/models/RuntimeControlServer.js.map +0 -1
- package/dist/models/RuntimeDebugLog.d.ts +0 -10
- package/dist/models/RuntimeDebugLog.js +0 -32
- package/dist/models/RuntimeDebugLog.js.map +0 -1
- package/dist/models/RuntimeEvent.d.ts +0 -95
- package/dist/models/RuntimeEvent.js +0 -2
- package/dist/models/RuntimeEvent.js.map +0 -1
- package/dist/models/SqliteDevORMStore.d.ts +0 -16
- package/dist/models/SqliteDevORMStore.js +0 -69
- package/dist/models/SqliteDevORMStore.js.map +0 -1
- package/dist/models/WorkflowRunJob.d.ts +0 -95
- package/dist/models/WorkflowRunJob.js +0 -2
- package/dist/models/WorkflowRunJob.js.map +0 -1
- package/dist/models/WorkflowWorkerPool.d.ts +0 -39
- package/dist/models/WorkflowWorkerPool.js +0 -154
- package/dist/models/WorkflowWorkerPool.js.map +0 -1
- package/dist/services/RuntimeEvents.service.d.ts +0 -16
- package/dist/services/RuntimeEvents.service.js +0 -35
- package/dist/services/RuntimeEvents.service.js.map +0 -1
- package/dist/services/WorkflowRunScheduler.service.d.ts +0 -62
- package/dist/services/WorkflowRunScheduler.service.js +0 -278
- package/dist/services/WorkflowRunScheduler.service.js.map +0 -1
- package/dist/tools/format-runtime-event.d.ts +0 -3
- package/dist/tools/format-runtime-event.js +0 -51
- package/dist/tools/format-runtime-event.js.map +0 -1
- package/dist/tools/run-workflow-run-job.d.ts +0 -3
- package/dist/tools/run-workflow-run-job.js +0 -25
- package/dist/tools/run-workflow-run-job.js.map +0 -1
- package/dist/tools/runtime-control-client.d.ts +0 -15
- package/dist/tools/runtime-control-client.js +0 -54
- package/dist/tools/runtime-control-client.js.map +0 -1
- package/dist/tools/runtime-registry.d.ts +0 -28
- package/dist/tools/runtime-registry.js +0 -57
- package/dist/tools/runtime-registry.js.map +0 -1
- package/dist/tools/start-runtime-monitor.d.ts +0 -13
- package/dist/tools/start-runtime-monitor.js +0 -70
- package/dist/tools/start-runtime-monitor.js.map +0 -1
- package/dist/tools/to-orm-config.d.ts +0 -3
- package/dist/tools/to-orm-config.js +0 -13
- package/dist/tools/to-orm-config.js.map +0 -1
- package/dist/tools/to-runtime-config.d.ts +0 -3
- package/dist/tools/to-runtime-config.js +0 -13
- package/dist/tools/to-runtime-config.js.map +0 -1
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.d.ts +0 -14
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.js +0 -55
- package/dist/use-cases/RejectAbandonedWorkflowRuns.usecase.js.map +0 -1
- package/dist/workers/workflow-worker.d.ts +0 -1
- package/dist/workers/workflow-worker.js +0 -58
- package/dist/workers/workflow-worker.js.map +0 -1
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type DevORMStore, type DevORMStoredRow } from './DevORMStore.js';
|
|
2
|
-
/**
|
|
3
|
-
* Stores the dev ORM rows in Postgres, one `(id text, data jsonb)` table per
|
|
4
|
-
* entity. Every workflow worker opens its own pool, sized to the jobs it runs
|
|
5
|
-
* at once, and writes from different workers no longer wait on a file lock.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PostgresDevORMStore implements DevORMStore {
|
|
8
|
-
private readonly pool;
|
|
9
|
-
private readonly tables;
|
|
10
|
-
constructor(connectionString: string, { max }?: {
|
|
11
|
-
max?: number;
|
|
12
|
-
});
|
|
13
|
-
insert(table: string, rows: DevORMStoredRow[]): Promise<void>;
|
|
14
|
-
get(table: string, id: string): Promise<string | null>;
|
|
15
|
-
getMany(table: string, ids: string[]): Promise<DevORMStoredRow[]>;
|
|
16
|
-
update(table: string, id: string, apply: (data: string) => Promise<string>): Promise<void>;
|
|
17
|
-
delete(table: string, ids: string[]): Promise<void>;
|
|
18
|
-
scan(table: string): Promise<string[]>;
|
|
19
|
-
close(): Promise<void>;
|
|
20
|
-
private table;
|
|
21
|
-
private createTable;
|
|
22
|
-
private transaction;
|
|
23
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
2
|
-
import { quoteTableName, } from './DevORMStore.js';
|
|
3
|
-
import { WORKFLOW_RUN_JOB_CONCURRENCY } from '../constants/server.js';
|
|
4
|
-
/**
|
|
5
|
-
* Stores the dev ORM rows in Postgres, one `(id text, data jsonb)` table per
|
|
6
|
-
* entity. Every workflow worker opens its own pool, sized to the jobs it runs
|
|
7
|
-
* at once, and writes from different workers no longer wait on a file lock.
|
|
8
|
-
*/
|
|
9
|
-
export class PostgresDevORMStore {
|
|
10
|
-
pool;
|
|
11
|
-
tables = new Map();
|
|
12
|
-
constructor(connectionString, { max = WORKFLOW_RUN_JOB_CONCURRENCY } = {}) {
|
|
13
|
-
this.pool = new pg.Pool({ connectionString, max });
|
|
14
|
-
// An idle connection dropped by the server must not crash the process.
|
|
15
|
-
this.pool.on('error', error => console.error('[orm] Postgres connection error:', error.message));
|
|
16
|
-
}
|
|
17
|
-
async insert(table, rows) {
|
|
18
|
-
if (rows.length === 0)
|
|
19
|
-
return;
|
|
20
|
-
await this.pool.query(`INSERT INTO ${await this.table(table)} (id, data)
|
|
21
|
-
SELECT * FROM unnest($1::text[], $2::jsonb[])`, [rows.map(row => row.id), rows.map(row => row.data)]);
|
|
22
|
-
}
|
|
23
|
-
async get(table, id) {
|
|
24
|
-
const { rows } = await this.pool.query(`SELECT data::text AS data FROM ${await this.table(table)} WHERE id = $1`, [id]);
|
|
25
|
-
return rows[0]?.data ?? null;
|
|
26
|
-
}
|
|
27
|
-
async getMany(table, ids) {
|
|
28
|
-
const { rows } = await this.pool.query(`SELECT id, data::text AS data FROM ${await this.table(table)} WHERE id = ANY($1::text[])`, [ids]);
|
|
29
|
-
return rows;
|
|
30
|
-
}
|
|
31
|
-
async update(table, id, apply) {
|
|
32
|
-
const quoted = await this.table(table);
|
|
33
|
-
await this.transaction(async (client) => {
|
|
34
|
-
// Locks the row so concurrent updates from other workers merge in turn.
|
|
35
|
-
const { rows } = await client.query(`SELECT data::text AS data FROM ${quoted} WHERE id = $1 FOR UPDATE`, [id]);
|
|
36
|
-
if (!rows[0])
|
|
37
|
-
return;
|
|
38
|
-
await client.query(`UPDATE ${quoted} SET data = $2::jsonb WHERE id = $1`, [id, await apply(rows[0].data)]);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async delete(table, ids) {
|
|
42
|
-
if (ids.length === 0)
|
|
43
|
-
return;
|
|
44
|
-
await this.pool.query(`DELETE FROM ${await this.table(table)} WHERE id = ANY($1::text[])`, [ids]);
|
|
45
|
-
}
|
|
46
|
-
async scan(table) {
|
|
47
|
-
const { rows } = await this.pool.query(`SELECT data::text AS data FROM ${await this.table(table)} ORDER BY id`);
|
|
48
|
-
return rows.map(row => row.data);
|
|
49
|
-
}
|
|
50
|
-
async close() {
|
|
51
|
-
this.tables.clear();
|
|
52
|
-
await this.pool.end();
|
|
53
|
-
}
|
|
54
|
-
table(name) {
|
|
55
|
-
let table = this.tables.get(name);
|
|
56
|
-
if (!table) {
|
|
57
|
-
table = this.createTable(name);
|
|
58
|
-
table.catch(() => this.tables.delete(name));
|
|
59
|
-
this.tables.set(name, table);
|
|
60
|
-
}
|
|
61
|
-
return table;
|
|
62
|
-
}
|
|
63
|
-
async createTable(name) {
|
|
64
|
-
const quoted = quoteTableName(name);
|
|
65
|
-
await this.transaction(async (client) => {
|
|
66
|
-
// Workers creating the same table at once would race on the catalog.
|
|
67
|
-
await client.query('SELECT pg_advisory_xact_lock(hashtext($1))', [name]);
|
|
68
|
-
await client.query(`CREATE TABLE IF NOT EXISTS ${quoted} (id TEXT PRIMARY KEY, data JSONB NOT NULL)`);
|
|
69
|
-
const { rows } = await client.query(`SELECT column_name AS name, data_type AS type
|
|
70
|
-
FROM information_schema.columns
|
|
71
|
-
WHERE table_schema = current_schema() AND table_name = $1`, [name]);
|
|
72
|
-
const columns = new Map(rows.map(row => [row.name, row.type]));
|
|
73
|
-
if (columns.get('id') !== 'text' || columns.get('data') !== 'jsonb')
|
|
74
|
-
throw new Error(`Table ${quoted} already exists without the dev ORM layout (id text, data jsonb); point orm.connectionString in framework.config at a database of its own`);
|
|
75
|
-
});
|
|
76
|
-
return quoted;
|
|
77
|
-
}
|
|
78
|
-
async transaction(fn) {
|
|
79
|
-
const client = await this.pool.connect();
|
|
80
|
-
try {
|
|
81
|
-
await client.query('BEGIN');
|
|
82
|
-
await fn(client);
|
|
83
|
-
await client.query('COMMIT');
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
await client.query('ROLLBACK').catch(() => { });
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
finally {
|
|
90
|
-
client.release();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=PostgresDevORMStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresDevORMStore.js","sourceRoot":"","sources":["../../src/models/PostgresDevORMStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,OAAO,EACL,cAAc,GAGf,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAErE;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IACb,IAAI,CAAS;IAEb,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAA;IAE5D,YACE,gBAAwB,EACxB,EAAE,GAAG,GAAG,4BAA4B,KAAuB,EAAE;QAE7D,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAA;QAElD,uEAAuE;QACvE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAC5B,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,OAAO,CAAC,CACjE,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,IAAuB;QACxD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QAE7B,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CACnB,eAAe,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;qDACS,EAC/C,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CACrD,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,EAAU;QACxC,MAAM,EAAE,IAAI,EAAE,GAAG,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,6CAA6C,CAClF,CAAA;YAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CACjC;;mEAE2D,EAC3D,CAAC,IAAI,CAAC,CACP,CAAA;YAED,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAE9D,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,OAAO;gBACjE,MAAM,IAAI,KAAK,CACb,SAAS,MAAM,2IAA2I,CAC3J,CAAA;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,EAA4C;QAE5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;QAExC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAE3B,MAAM,EAAE,CAAC,MAAM,CAAC,CAAA;YAEhB,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAE9C,MAAM,KAAK,CAAA;QACb,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RuntimeEvent } from './RuntimeEvent.js';
|
|
2
|
-
import type { RuntimeEventsService } from '../services/RuntimeEvents.service.js';
|
|
3
|
-
import { type RuntimeInfo, type RuntimeStatus } from '../tools/runtime-registry.js';
|
|
4
|
-
/** First line a client sends; the server answers with NDJSON lines. */
|
|
5
|
-
export interface RuntimeControlRequest {
|
|
6
|
-
method: 'status' | 'watch';
|
|
7
|
-
}
|
|
8
|
-
export type RuntimeControlMessage = ({
|
|
9
|
-
type: 'status';
|
|
10
|
-
} & RuntimeStatus) | {
|
|
11
|
-
type: 'event';
|
|
12
|
-
event: RuntimeEvent;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'error';
|
|
15
|
-
message: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Local socket (named pipe on Windows) through which `framework runtime`
|
|
19
|
-
* reads the status of this app process and follows its events.
|
|
20
|
-
*/
|
|
21
|
-
export declare class RuntimeControlServer {
|
|
22
|
-
private readonly info;
|
|
23
|
-
private readonly status;
|
|
24
|
-
private readonly events;
|
|
25
|
-
private readonly server;
|
|
26
|
-
constructor(info: RuntimeInfo, status: () => Promise<RuntimeStatus>, events: RuntimeEventsService);
|
|
27
|
-
start(): Promise<void>;
|
|
28
|
-
/** Synchronous so it can run in a process `exit` handler. */
|
|
29
|
-
close(): void;
|
|
30
|
-
private onConnection;
|
|
31
|
-
private handle;
|
|
32
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import net from 'node:net';
|
|
3
|
-
import { runtimeRegistryDir, runtimeRegistryFile, } from '../tools/runtime-registry.js';
|
|
4
|
-
const send = (socket, message) => socket.write(`${JSON.stringify(message)}\n`);
|
|
5
|
-
/**
|
|
6
|
-
* Local socket (named pipe on Windows) through which `framework runtime`
|
|
7
|
-
* reads the status of this app process and follows its events.
|
|
8
|
-
*/
|
|
9
|
-
export class RuntimeControlServer {
|
|
10
|
-
info;
|
|
11
|
-
status;
|
|
12
|
-
events;
|
|
13
|
-
server;
|
|
14
|
-
constructor(info, status, events) {
|
|
15
|
-
this.info = info;
|
|
16
|
-
this.status = status;
|
|
17
|
-
this.events = events;
|
|
18
|
-
this.server = net.createServer(socket => this.onConnection(socket));
|
|
19
|
-
}
|
|
20
|
-
async start() {
|
|
21
|
-
fs.mkdirSync(runtimeRegistryDir(), { recursive: true, mode: 0o700 });
|
|
22
|
-
if (process.platform !== 'win32')
|
|
23
|
-
fs.rmSync(this.info.socket, { force: true });
|
|
24
|
-
await new Promise((resolve, reject) => {
|
|
25
|
-
this.server.once('error', reject);
|
|
26
|
-
this.server.listen(this.info.socket, () => {
|
|
27
|
-
this.server.off('error', reject);
|
|
28
|
-
resolve();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
fs.writeFileSync(runtimeRegistryFile(this.info.pid), JSON.stringify(this.info, null, 2));
|
|
32
|
-
}
|
|
33
|
-
/** Synchronous so it can run in a process `exit` handler. */
|
|
34
|
-
close() {
|
|
35
|
-
this.server.close();
|
|
36
|
-
fs.rmSync(runtimeRegistryFile(this.info.pid), { force: true });
|
|
37
|
-
if (process.platform !== 'win32')
|
|
38
|
-
fs.rmSync(this.info.socket, { force: true });
|
|
39
|
-
}
|
|
40
|
-
onConnection(socket) {
|
|
41
|
-
let buffer = '';
|
|
42
|
-
socket.setEncoding('utf8');
|
|
43
|
-
socket.on('error', () => socket.destroy());
|
|
44
|
-
const onData = (chunk) => {
|
|
45
|
-
buffer += chunk;
|
|
46
|
-
const end = buffer.indexOf('\n');
|
|
47
|
-
if (end === -1)
|
|
48
|
-
return;
|
|
49
|
-
socket.off('data', onData);
|
|
50
|
-
void this.handle(socket, buffer.slice(0, end));
|
|
51
|
-
};
|
|
52
|
-
socket.on('data', onData);
|
|
53
|
-
}
|
|
54
|
-
async handle(socket, line) {
|
|
55
|
-
let request;
|
|
56
|
-
try {
|
|
57
|
-
request = JSON.parse(line);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
send(socket, { type: 'error', message: 'Invalid request' });
|
|
61
|
-
return void socket.end();
|
|
62
|
-
}
|
|
63
|
-
if (request.method !== 'status' && request.method !== 'watch') {
|
|
64
|
-
send(socket, { type: 'error', message: 'Unknown method' });
|
|
65
|
-
return void socket.end();
|
|
66
|
-
}
|
|
67
|
-
send(socket, { type: 'status', ...(await this.status()) });
|
|
68
|
-
if (request.method === 'status')
|
|
69
|
-
return void socket.end();
|
|
70
|
-
const forward = (event) => send(socket, { type: 'event', event });
|
|
71
|
-
this.events.on('event', forward);
|
|
72
|
-
socket.once('close', () => this.events.off('event', forward));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=RuntimeControlServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeControlServer.js","sourceRoot":"","sources":["../../src/models/RuntimeControlServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,GAAG,MAAM,UAAU,CAAA;AAI1B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAGpB,MAAM,8BAA8B,CAAA;AAYrC,MAAM,IAAI,GAAG,CAAC,MAAkB,EAAE,OAA8B,EAAE,EAAE,CAClE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAIZ;IACA;IACA;IALF,MAAM,CAAY;IAEnC,YACmB,IAAiB,EACjB,MAAoC,EACpC,MAA4B;QAF5B,SAAI,GAAJ,IAAI,CAAa;QACjB,WAAM,GAAN,MAAM,CAA8B;QACpC,WAAM,GAAN,MAAM,CAAsB;QAE7C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;IACrE,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,EAAE,CAAC,SAAS,CAAC,kBAAkB,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;Q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AA;QAE1D,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ;YAAE,OAAO,KAAK,MAAM,CAAC,GAAG,EAAE,CAAA;QAEzD,MAAM,OAAO,GAAG,CAAC,KAAmB,EAAE,EAAE,CACtC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;QAExC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAEhC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC/D,CAAC;CACF"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RuntimeEvent } from './RuntimeEvent.js';
|
|
2
|
-
/** `-` writes readable lines to stderr; a path appends NDJSON to that file. */
|
|
3
|
-
export declare const DEBUG_LOG_STDERR = "-";
|
|
4
|
-
export declare class RuntimeDebugLog {
|
|
5
|
-
private readonly toStderr;
|
|
6
|
-
private fd;
|
|
7
|
-
constructor(target: string);
|
|
8
|
-
readonly write: (event: RuntimeEvent) => void;
|
|
9
|
-
close(): void;
|
|
10
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { formatRuntimeEvent } from '../tools/format-runtime-event.js';
|
|
4
|
-
/** `-` writes readable lines to stderr; a path appends NDJSON to that file. */
|
|
5
|
-
export const DEBUG_LOG_STDERR = '-';
|
|
6
|
-
export class RuntimeDebugLog {
|
|
7
|
-
toStderr;
|
|
8
|
-
// Written synchronously: the app process may exit right after an event.
|
|
9
|
-
fd = null;
|
|
10
|
-
constructor(target) {
|
|
11
|
-
this.toStderr = target === DEBUG_LOG_STDERR;
|
|
12
|
-
if (this.toStderr)
|
|
13
|
-
return;
|
|
14
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
15
|
-
this.fd = fs.openSync(target, 'a');
|
|
16
|
-
}
|
|
17
|
-
write = (event) => {
|
|
18
|
-
if (this.toStderr) {
|
|
19
|
-
process.stderr.write(`[runtime] ${formatRuntimeEvent(event)}\n`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (this.fd !== null)
|
|
23
|
-
fs.writeSync(this.fd, `${JSON.stringify(event)}\n`);
|
|
24
|
-
};
|
|
25
|
-
close() {
|
|
26
|
-
if (this.fd === null)
|
|
27
|
-
return;
|
|
28
|
-
fs.closeSync(this.fd);
|
|
29
|
-
this.fd = null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=RuntimeDebugLog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeDebugLog.js","sourceRoot":"","sources":["../../src/models/RuntimeDebugLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAErE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAEnC,MAAM,OAAO,eAAe;IACT,QAAQ,CAAS;IAElC,wEAAwE;IAChE,EAAE,GAAkB,IAAI,CAAA;IAEhC,YAAY,MAAc;QACxB,IAAI,CAAC,QAAQ,GAAG,MAAM,KAAK,gBAAgB,CAAA;QAE3C,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAM;QAEzB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAEvD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC;IAEe,KAAK,GAAG,CAAC,KAAmB,EAAQ,EAAE;QACpD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAEhE,OAAM;QACR,CAAC;QAED,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI;YAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3E,CAAC,CAAA;IAEM,KAAK;QACV,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI;YAAE,OAAM;QAE5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAErB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;IAChB,CAAC;CACF"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { WorkflowRunJobKind } from './WorkflowRunJob.js';
|
|
2
|
-
/** A job as runtime events describe it: what it is, never its payload. */
|
|
3
|
-
export interface RuntimeJobSummary {
|
|
4
|
-
kind: WorkflowRunJobKind;
|
|
5
|
-
runId: string | null;
|
|
6
|
-
/** The activity, pending or child run the job is about, when there is one. */
|
|
7
|
-
target: string | null;
|
|
8
|
-
}
|
|
9
|
-
export interface RuntimeLaneStats {
|
|
10
|
-
lane: number;
|
|
11
|
-
inFlight: number;
|
|
12
|
-
pinnedRuns: number;
|
|
13
|
-
}
|
|
14
|
-
export interface RuntimeQueueStats {
|
|
15
|
-
workers: number;
|
|
16
|
-
concurrency: number;
|
|
17
|
-
capacity: number;
|
|
18
|
-
queued: number;
|
|
19
|
-
urgent: number;
|
|
20
|
-
inFlight: number;
|
|
21
|
-
lanes: RuntimeLaneStats[];
|
|
22
|
-
}
|
|
23
|
-
export interface RuntimeRunningJob extends RuntimeJobSummary {
|
|
24
|
-
lane: number;
|
|
25
|
-
startedAt: string;
|
|
26
|
-
}
|
|
27
|
-
export interface RuntimeQueueSnapshot extends RuntimeQueueStats {
|
|
28
|
-
running: RuntimeRunningJob[];
|
|
29
|
-
waiting: RuntimeJobSummary[];
|
|
30
|
-
}
|
|
31
|
-
/** Something the runtime did, published on the coordinator. */
|
|
32
|
-
export type RuntimeEventBody = {
|
|
33
|
-
type: 'job:queued';
|
|
34
|
-
job: RuntimeJobSummary;
|
|
35
|
-
queue: RuntimeQueueStats;
|
|
36
|
-
} | {
|
|
37
|
-
type: 'job:started';
|
|
38
|
-
job: RuntimeJobSummary;
|
|
39
|
-
lane: number;
|
|
40
|
-
queue: RuntimeQueueStats;
|
|
41
|
-
} | {
|
|
42
|
-
type: 'job:finished';
|
|
43
|
-
job: RuntimeJobSummary;
|
|
44
|
-
lane: number;
|
|
45
|
-
durationInMs: number;
|
|
46
|
-
error: string | null;
|
|
47
|
-
queue: RuntimeQueueStats;
|
|
48
|
-
} | {
|
|
49
|
-
type: 'run:created';
|
|
50
|
-
runId: string;
|
|
51
|
-
workflow: string;
|
|
52
|
-
parentRunId: string | null;
|
|
53
|
-
} | {
|
|
54
|
-
type: 'run:settled';
|
|
55
|
-
runId: string;
|
|
56
|
-
workflow: string;
|
|
57
|
-
status: 'fulfilled' | 'rejected';
|
|
58
|
-
} | {
|
|
59
|
-
type: 'activity:started';
|
|
60
|
-
runId: string;
|
|
61
|
-
activityId: string;
|
|
62
|
-
activityType: string;
|
|
63
|
-
kind: 'sync' | 'async';
|
|
64
|
-
} | {
|
|
65
|
-
type: 'activity:waiting';
|
|
66
|
-
runId: string;
|
|
67
|
-
activityId: string;
|
|
68
|
-
activityType: string;
|
|
69
|
-
timeoutAt: string | null;
|
|
70
|
-
} | {
|
|
71
|
-
type: 'activity:settled';
|
|
72
|
-
runId: string;
|
|
73
|
-
activityId: string;
|
|
74
|
-
activityType: string;
|
|
75
|
-
status: 'fulfilled' | 'rejected';
|
|
76
|
-
/** Why a sync activity or a bootstrap threw, when it did. */
|
|
77
|
-
error?: string;
|
|
78
|
-
} | {
|
|
79
|
-
type: 'timeout:scheduled';
|
|
80
|
-
runId: string;
|
|
81
|
-
pendingId: string;
|
|
82
|
-
timeoutAt: string;
|
|
83
|
-
} | {
|
|
84
|
-
type: 'timeout:fired';
|
|
85
|
-
runId: string;
|
|
86
|
-
pendingId: string;
|
|
87
|
-
} | {
|
|
88
|
-
type: 'worker:lost';
|
|
89
|
-
lane: number;
|
|
90
|
-
error: string;
|
|
91
|
-
};
|
|
92
|
-
export type RuntimeEvent = RuntimeEventBody & {
|
|
93
|
-
at: string;
|
|
94
|
-
};
|
|
95
|
-
export type RuntimeEventType = RuntimeEvent['type'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeEvent.js","sourceRoot":"","sources":["../../src/models/RuntimeEvent.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type DevORMStore, type DevORMStoredRow } from './DevORMStore.js';
|
|
2
|
-
export declare class SqliteDevORMStore implements DevORMStore {
|
|
3
|
-
private readonly location;
|
|
4
|
-
private database;
|
|
5
|
-
private readonly tables;
|
|
6
|
-
constructor(location?: string);
|
|
7
|
-
insert(table: string, rows: DevORMStoredRow[]): Promise<void>;
|
|
8
|
-
get(table: string, id: string): Promise<string | null>;
|
|
9
|
-
getMany(table: string, ids: string[]): Promise<DevORMStoredRow[]>;
|
|
10
|
-
update(table: string, id: string, apply: (data: string) => Promise<string>): Promise<void>;
|
|
11
|
-
delete(table: string, ids: string[]): Promise<void>;
|
|
12
|
-
scan(table: string): Promise<string[]>;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
private get db();
|
|
15
|
-
private table;
|
|
16
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { DatabaseSync } from 'node:sqlite';
|
|
3
|
-
import { quoteTableName, } from './DevORMStore.js';
|
|
4
|
-
const BUSY_TIMEOUT_IN_MS = 5_000;
|
|
5
|
-
export class SqliteDevORMStore {
|
|
6
|
-
location;
|
|
7
|
-
database = null;
|
|
8
|
-
tables = new Set();
|
|
9
|
-
constructor(location = path.join(process.cwd(), 'db.sqlite')) {
|
|
10
|
-
this.location = location;
|
|
11
|
-
}
|
|
12
|
-
async insert(table, rows) {
|
|
13
|
-
const insert = this.db.prepare(`INSERT INTO ${this.table(table)} (id, data) VALUES (?, ?)`);
|
|
14
|
-
for (const { id, data } of rows)
|
|
15
|
-
insert.run(id, data);
|
|
16
|
-
}
|
|
17
|
-
async get(table, id) {
|
|
18
|
-
const row = this.db
|
|
19
|
-
.prepare(`SELECT data FROM ${this.table(table)} WHERE id = ?`)
|
|
20
|
-
.get(id);
|
|
21
|
-
return row?.data ?? null;
|
|
22
|
-
}
|
|
23
|
-
async getMany(table, ids) {
|
|
24
|
-
return this.db
|
|
25
|
-
.prepare(`SELECT id, data FROM ${this.table(table)} WHERE id IN (SELECT value FROM json_each(?))`)
|
|
26
|
-
.all(JSON.stringify(ids));
|
|
27
|
-
}
|
|
28
|
-
async update(table, id, apply) {
|
|
29
|
-
const current = await this.get(table, id);
|
|
30
|
-
if (current === null)
|
|
31
|
-
return;
|
|
32
|
-
this.db
|
|
33
|
-
.prepare(`UPDATE ${this.table(table)} SET data = ? WHERE id = ?`)
|
|
34
|
-
.run(await apply(current), id);
|
|
35
|
-
}
|
|
36
|
-
async delete(table, ids) {
|
|
37
|
-
const statement = this.db.prepare(`DELETE FROM ${this.table(table)} WHERE id = ?`);
|
|
38
|
-
for (const id of ids)
|
|
39
|
-
statement.run(id);
|
|
40
|
-
}
|
|
41
|
-
async scan(table) {
|
|
42
|
-
const rows = this.db
|
|
43
|
-
.prepare(`SELECT data FROM ${this.table(table)} ORDER BY id`)
|
|
44
|
-
.all();
|
|
45
|
-
return rows.map(row => row.data);
|
|
46
|
-
}
|
|
47
|
-
async close() {
|
|
48
|
-
this.database?.close();
|
|
49
|
-
this.database = null;
|
|
50
|
-
this.tables.clear();
|
|
51
|
-
}
|
|
52
|
-
get db() {
|
|
53
|
-
if (this.database)
|
|
54
|
-
return this.database;
|
|
55
|
-
this.database = new DatabaseSync(this.location);
|
|
56
|
-
// Workflow workers open their own connection to the same file.
|
|
57
|
-
this.database.exec(`PRAGMA busy_timeout = ${BUSY_TIMEOUT_IN_MS}`);
|
|
58
|
-
return this.database;
|
|
59
|
-
}
|
|
60
|
-
table(name) {
|
|
61
|
-
const quoted = quoteTableName(name);
|
|
62
|
-
if (!this.tables.has(name)) {
|
|
63
|
-
this.db.exec(`CREATE TABLE IF NOT EXISTS ${quoted} (id TEXT PRIMARY KEY, data TEXT NOT NULL)`);
|
|
64
|
-
this.tables.add(name);
|
|
65
|
-
}
|
|
66
|
-
return quoted;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=SqliteDevORMStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteDevORMStore.js","sourceRoot":"","sources":["../../src/models/SqliteDevORMStore.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EACL,cAAc,GAGf,MAAM,kBAAkB,CAAA;AAEzB,MAAM,kBAAkB,GAAG,KAAK,CAAA;AAEhC,MAAM,OAAO,iBAAiB;IAMT;IALX,QAAQ,GAAwB,IAAI,CAAA;IAE3B,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;IAE3C,YACmB,WAAW,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC;QAAhD,aAAQ,GAAR,QAAQ,CAAwC;IAChE,CAAC;IAEG,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,IAAuB;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAC5B,eAAe,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,2BAA2B,CAC5D,CAAA;QAED,KAAK,MAAM,E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} from './RuntimeEvent.js';
|
|
3
|
-
/**
|
|
4
|
-
* Unit of work the scheduler hands to an executor. Jobs carrying a `runId`
|
|
5
|
-
* are serialized per run and pinned to the executor lane that first ran it,
|
|
6
|
-
* since activity constructors only live in the thread that pushed them.
|
|
7
|
-
*/
|
|
8
|
-
export type WorkflowRunJob = {
|
|
9
|
-
kind: 'run.tick';
|
|
10
|
-
runId: string;
|
|
11
|
-
} | {
|
|
12
|
-
kind: 'run.settle-parent';
|
|
13
|
-
runId: string;
|
|
14
|
-
childRunId: string;
|
|
15
|
-
} | {
|
|
16
|
-
kind: 'pending.execute';
|
|
17
|
-
runId: string;
|
|
18
|
-
pendingId: string;
|
|
19
|
-
} | {
|
|
20
|
-
kind: 'activity.advance';
|
|
21
|
-
runId?: string;
|
|
22
|
-
activityId: string;
|
|
23
|
-
payload: unknown;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'callback.create';
|
|
26
|
-
runId?: string;
|
|
27
|
-
activityId: string;
|
|
28
|
-
token: string;
|
|
29
|
-
request: AsyncActivityCallback.Delivery;
|
|
30
|
-
} | {
|
|
31
|
-
kind: 'event.deliver';
|
|
32
|
-
runId: string;
|
|
33
|
-
activityId: string;
|
|
34
|
-
pendingId: string;
|
|
35
|
-
delivery: AsyncActivityCallback.Delivery;
|
|
36
|
-
} | {
|
|
37
|
-
kind: 'event.correlate';
|
|
38
|
-
event: AsyncActivityCallback.Event;
|
|
39
|
-
};
|
|
40
|
-
export type WorkflowRunJobKind = WorkflowRunJob['kind'];
|
|
41
|
-
export interface SerializedJobError {
|
|
42
|
-
name: string;
|
|
43
|
-
message: string;
|
|
44
|
-
stack?: string;
|
|
45
|
-
code?: number;
|
|
46
|
-
data?: unknown;
|
|
47
|
-
}
|
|
48
|
-
/** Messages a workflow worker sends back to the coordinator thread. */
|
|
49
|
-
export type WorkflowWorkerMessage = {
|
|
50
|
-
type: 'ready';
|
|
51
|
-
} | {
|
|
52
|
-
type: 'boot-failed';
|
|
53
|
-
error: SerializedJobError;
|
|
54
|
-
} | {
|
|
55
|
-
type: 'job:fulfilled';
|
|
56
|
-
id: number;
|
|
57
|
-
value: unknown;
|
|
58
|
-
} | {
|
|
59
|
-
type: 'job:rejected';
|
|
60
|
-
id: number;
|
|
61
|
-
error: SerializedJobError;
|
|
62
|
-
} | {
|
|
63
|
-
type: 'queue:enqueue';
|
|
64
|
-
job: WorkflowRunJob;
|
|
65
|
-
} | {
|
|
66
|
-
type: 'timeout:schedule';
|
|
67
|
-
runId: string;
|
|
68
|
-
pendingId: string;
|
|
69
|
-
timeoutAt: number;
|
|
70
|
-
} | {
|
|
71
|
-
type: 'timeout:cancel';
|
|
72
|
-
pendingId: string;
|
|
73
|
-
} | {
|
|
74
|
-
type: 'events:run-created';
|
|
75
|
-
payload: unknown;
|
|
76
|
-
} | {
|
|
77
|
-
type: 'events:run-updated';
|
|
78
|
-
runId: string;
|
|
79
|
-
} | {
|
|
80
|
-
type: 'runtime:event';
|
|
81
|
-
event: RuntimeEvent;
|
|
82
|
-
};
|
|
83
|
-
/** Messages the coordinator thread sends to a workflow worker. */
|
|
84
|
-
export type WorkflowCoordinatorMessage = {
|
|
85
|
-
type: 'job';
|
|
86
|
-
id: number;
|
|
87
|
-
job: WorkflowRunJob;
|
|
88
|
-
};
|
|
89
|
-
export interface WorkflowWorkerData {
|
|
90
|
-
entrypoint: string;
|
|
91
|
-
env: [string, string][];
|
|
92
|
-
serverUrl: string | null;
|
|
93
|
-
databaseLocation: string;
|
|
94
|
-
callbackSecret: string;
|
|
95
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowRunJob.js","sourceRoot":"","sources":["../../src/models/WorkflowRunJob.ts"],"names":[],"mappings":""}
|
|
@@ -1,39 +0,0 @@
|
|
|
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 {};
|