@lotiai/composer 0.2.0 → 0.2.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/build-config/index.d.ts +52 -0
- package/dist/build-config/index.d.ts.map +1 -0
- package/dist/build-config/index.js +66 -0
- package/dist/build-config/index.js.map +1 -0
- package/dist/build-config/loader.d.ts +80 -0
- package/dist/build-config/loader.d.ts.map +1 -0
- package/dist/build-config/loader.js +238 -0
- package/dist/build-config/loader.js.map +1 -0
- package/dist/build-config/schema.d.ts +101 -0
- package/dist/build-config/schema.d.ts.map +1 -0
- package/dist/build-config/schema.js +94 -0
- package/dist/build-config/schema.js.map +1 -0
- package/dist/cli/commands/dev-temporal.d.ts +15 -0
- package/dist/cli/commands/dev-temporal.d.ts.map +1 -0
- package/dist/cli/commands/dev-temporal.js +68 -0
- package/dist/cli/commands/dev-temporal.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +21 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +421 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/profiles.d.ts +15 -0
- package/dist/cli/commands/profiles.d.ts.map +1 -0
- package/dist/cli/commands/profiles.js +69 -0
- package/dist/cli/commands/profiles.js.map +1 -0
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +44 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/async/build/workflow-factory.d.ts +212 -0
- package/dist/internal/async/build/workflow-factory.d.ts.map +1 -0
- package/dist/internal/async/build/workflow-factory.js +533 -0
- package/dist/internal/async/build/workflow-factory.js.map +1 -0
- package/dist/internal/async/build-scripts/utils/common.d.ts +28 -0
- package/dist/internal/async/build-scripts/utils/common.d.ts.map +1 -0
- package/dist/internal/async/build-scripts/utils/common.js +50 -0
- package/dist/internal/async/build-scripts/utils/common.js.map +1 -0
- package/dist/internal/async/build-scripts/utils/import-module.d.ts +19 -0
- package/dist/internal/async/build-scripts/utils/import-module.d.ts.map +1 -0
- package/dist/internal/async/build-scripts/utils/import-module.js +80 -0
- package/dist/internal/async/build-scripts/utils/import-module.js.map +1 -0
- package/dist/internal/async/build-scripts/utils/type-guards.d.ts +123 -0
- package/dist/internal/async/build-scripts/utils/type-guards.d.ts.map +1 -0
- package/dist/internal/async/build-scripts/utils/type-guards.js +145 -0
- package/dist/internal/async/build-scripts/utils/type-guards.js.map +1 -0
- package/dist/internal/async/config/cleanup-policy.d.ts +50 -0
- package/dist/internal/async/config/cleanup-policy.d.ts.map +1 -0
- package/dist/internal/async/config/cleanup-policy.js +20 -0
- package/dist/internal/async/config/cleanup-policy.js.map +1 -0
- package/dist/internal/async/config/worker-profiles.d.ts +172 -0
- package/dist/internal/async/config/worker-profiles.d.ts.map +1 -0
- package/dist/internal/async/config/worker-profiles.js +275 -0
- package/dist/internal/async/config/worker-profiles.js.map +1 -0
- package/dist/internal/async/execute/temporal-client.d.ts +182 -0
- package/dist/internal/async/execute/temporal-client.d.ts.map +1 -0
- package/dist/internal/async/execute/temporal-client.js +190 -0
- package/dist/internal/async/execute/temporal-client.js.map +1 -0
- package/dist/internal/async/execute/workflow-execution.d.ts +98 -0
- package/dist/internal/async/execute/workflow-execution.d.ts.map +1 -0
- package/dist/internal/async/execute/workflow-execution.js +191 -0
- package/dist/internal/async/execute/workflow-execution.js.map +1 -0
- package/dist/internal/async/metrics/task-queue-metrics.d.ts +74 -0
- package/dist/internal/async/metrics/task-queue-metrics.d.ts.map +1 -0
- package/dist/internal/async/metrics/task-queue-metrics.js +155 -0
- package/dist/internal/async/metrics/task-queue-metrics.js.map +1 -0
- package/dist/internal/async/register/activity-worker.d.ts +123 -0
- package/dist/internal/async/register/activity-worker.d.ts.map +1 -0
- package/dist/internal/async/register/activity-worker.js +355 -0
- package/dist/internal/async/register/activity-worker.js.map +1 -0
- package/dist/internal/async/register/generate-workflow-source.d.ts +43 -0
- package/dist/internal/async/register/generate-workflow-source.d.ts.map +1 -0
- package/dist/internal/async/register/generate-workflow-source.js +193 -0
- package/dist/internal/async/register/generate-workflow-source.js.map +1 -0
- package/dist/internal/async/register/workflow-worker.d.ts +125 -0
- package/dist/internal/async/register/workflow-worker.d.ts.map +1 -0
- package/dist/internal/async/register/workflow-worker.js +215 -0
- package/dist/internal/async/register/workflow-worker.js.map +1 -0
- package/dist/internal/async/register-scripts/start-activity-worker.d.ts +70 -0
- package/dist/internal/async/register-scripts/start-activity-worker.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/start-activity-worker.js +75 -0
- package/dist/internal/async/register-scripts/start-activity-worker.js.map +1 -0
- package/dist/internal/async/register-scripts/start-all-workers.d.ts +81 -0
- package/dist/internal/async/register-scripts/start-all-workers.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/start-all-workers.js +84 -0
- package/dist/internal/async/register-scripts/start-all-workers.js.map +1 -0
- package/dist/internal/async/register-scripts/start-workflow-worker.d.ts +69 -0
- package/dist/internal/async/register-scripts/start-workflow-worker.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/start-workflow-worker.js +74 -0
- package/dist/internal/async/register-scripts/start-workflow-worker.js.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules-cli.d.ts +28 -0
- package/dist/internal/async/register-scripts/sync-schedules-cli.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules-cli.js +124 -0
- package/dist/internal/async/register-scripts/sync-schedules-cli.js.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules-via-lambda.d.ts +55 -0
- package/dist/internal/async/register-scripts/sync-schedules-via-lambda.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules-via-lambda.js +146 -0
- package/dist/internal/async/register-scripts/sync-schedules-via-lambda.js.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules.d.ts +68 -0
- package/dist/internal/async/register-scripts/sync-schedules.d.ts.map +1 -0
- package/dist/internal/async/register-scripts/sync-schedules.js +83 -0
- package/dist/internal/async/register-scripts/sync-schedules.js.map +1 -0
- package/dist/internal/async/schedule/constants.d.ts +10 -0
- package/dist/internal/async/schedule/constants.d.ts.map +1 -0
- package/dist/internal/async/schedule/constants.js +13 -0
- package/dist/internal/async/schedule/constants.js.map +1 -0
- package/dist/internal/async/schedule/define-schedule.d.ts +192 -0
- package/dist/internal/async/schedule/define-schedule.d.ts.map +1 -0
- package/dist/internal/async/schedule/define-schedule.js +79 -0
- package/dist/internal/async/schedule/define-schedule.js.map +1 -0
- package/dist/internal/async/schedule/index.d.ts +3 -0
- package/dist/internal/async/schedule/index.d.ts.map +1 -0
- package/dist/internal/async/schedule/index.js +9 -0
- package/dist/internal/async/schedule/index.js.map +1 -0
- package/dist/internal/async/schedule/schedule-definition-schema.d.ts +64 -0
- package/dist/internal/async/schedule/schedule-definition-schema.d.ts.map +1 -0
- package/dist/internal/async/schedule/schedule-definition-schema.js +77 -0
- package/dist/internal/async/schedule/schedule-definition-schema.js.map +1 -0
- package/dist/internal/async/schedule/sync-schedules.d.ts +71 -0
- package/dist/internal/async/schedule/sync-schedules.d.ts.map +1 -0
- package/dist/internal/async/schedule/sync-schedules.js +231 -0
- package/dist/internal/async/schedule/sync-schedules.js.map +1 -0
- package/dist/internal/async/utils/ensure-namespace.d.ts +16 -0
- package/dist/internal/async/utils/ensure-namespace.d.ts.map +1 -0
- package/dist/internal/async/utils/ensure-namespace.js +64 -0
- package/dist/internal/async/utils/ensure-namespace.js.map +1 -0
- package/dist/internal/async/utils/find-package-root.d.ts +9 -0
- package/dist/internal/async/utils/find-package-root.d.ts.map +1 -0
- package/dist/internal/async/utils/find-package-root.js +28 -0
- package/dist/internal/async/utils/find-package-root.js.map +1 -0
- package/dist/internal/async/utils/is-composer-error.d.ts +14 -0
- package/dist/internal/async/utils/is-composer-error.d.ts.map +1 -0
- package/dist/internal/async/utils/is-composer-error.js +17 -0
- package/dist/internal/async/utils/is-composer-error.js.map +1 -0
- package/dist/internal/context-provider.d.ts +316 -0
- package/dist/internal/context-provider.d.ts.map +1 -0
- package/dist/internal/context-provider.js +12 -0
- package/dist/internal/context-provider.js.map +1 -0
- package/dist/internal/create-composer.d.ts +57 -0
- package/dist/internal/create-composer.d.ts.map +1 -0
- package/dist/internal/create-composer.js +125 -0
- package/dist/internal/create-composer.js.map +1 -0
- package/dist/internal/dag-sync-fanout.d.ts +79 -0
- package/dist/internal/dag-sync-fanout.d.ts.map +1 -0
- package/dist/internal/dag-sync-fanout.js +59 -0
- package/dist/internal/dag-sync-fanout.js.map +1 -0
- package/dist/internal/dag-sync-step.d.ts +230 -0
- package/dist/internal/dag-sync-step.d.ts.map +1 -0
- package/dist/internal/dag-sync-step.js +159 -0
- package/dist/internal/dag-sync-step.js.map +1 -0
- package/dist/internal/dag-sync-workflow.d.ts +535 -0
- package/dist/internal/dag-sync-workflow.d.ts.map +1 -0
- package/dist/internal/dag-sync-workflow.js +843 -0
- package/dist/internal/dag-sync-workflow.js.map +1 -0
- package/dist/internal/defaults.d.ts +24 -0
- package/dist/internal/defaults.d.ts.map +1 -0
- package/dist/internal/defaults.js +102 -0
- package/dist/internal/defaults.js.map +1 -0
- package/dist/internal/errors.d.ts +109 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +212 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/index.d.ts +9 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +22 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/internal/observability.d.ts +63 -0
- package/dist/internal/observability.d.ts.map +1 -0
- package/dist/internal/observability.js +323 -0
- package/dist/internal/observability.js.map +1 -0
- package/dist/internal/types.d.ts +80 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +9 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/internal/workflow-planning.d.ts +107 -0
- package/dist/internal/workflow-planning.d.ts.map +1 -0
- package/dist/internal/workflow-planning.js +216 -0
- package/dist/internal/workflow-planning.js.map +1 -0
- package/dist/schedule-sync.d.ts +17 -0
- package/dist/schedule-sync.d.ts.map +1 -0
- package/dist/schedule-sync.js +22 -0
- package/dist/schedule-sync.js.map +1 -0
- package/dist/temporal-naming.d.ts +27 -0
- package/dist/temporal-naming.d.ts.map +1 -0
- package/dist/temporal-naming.js +33 -0
- package/dist/temporal-naming.js.map +1 -0
- package/package.json +16 -17
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Execution Integration for Temporal
|
|
3
|
+
*
|
|
4
|
+
* This module provides the integration layer between the synchronous workflow API
|
|
5
|
+
* (runWorkflow) and the Temporal async execution runtime. It bridges the gap by:
|
|
6
|
+
* - Converting sync workflow definitions to Temporal inputs
|
|
7
|
+
* - Integrating with the observability system (metrics/tracing)
|
|
8
|
+
* - Managing workflow lifecycle (start/success/failure)
|
|
9
|
+
* - Supporting early returns via checkpoints
|
|
10
|
+
*
|
|
11
|
+
* This is the glue layer that makes Temporal execution transparent to users of
|
|
12
|
+
* the synchronous runWorkflow() API.
|
|
13
|
+
*
|
|
14
|
+
* @module workflow-execution
|
|
15
|
+
*/
|
|
16
|
+
import type { VersioningOverride } from "@temporalio/common";
|
|
17
|
+
import { type Workflow, type WorkflowResult } from "../../dag-sync-workflow";
|
|
18
|
+
import type { UUIDV7 } from "../../types";
|
|
19
|
+
/**
|
|
20
|
+
* Options for Temporal workflow execution.
|
|
21
|
+
*/
|
|
22
|
+
export interface TemporalExecutionOptions {
|
|
23
|
+
workflowId: UUIDV7;
|
|
24
|
+
/**
|
|
25
|
+
* Temporal server connection configuration.
|
|
26
|
+
*/
|
|
27
|
+
clientConfig: {
|
|
28
|
+
address: string;
|
|
29
|
+
namespace: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Versioning override for Worker Versioning.
|
|
33
|
+
*/
|
|
34
|
+
versioningOverride?: VersioningOverride;
|
|
35
|
+
/**
|
|
36
|
+
* Optional checkpoint name to await.
|
|
37
|
+
* If specified, returns partial bag state when checkpoint is reached
|
|
38
|
+
* instead of waiting for full workflow completion.
|
|
39
|
+
*
|
|
40
|
+
* The checkpoint must exist in the workflow definition.
|
|
41
|
+
* Timeout is determined by the checkpoint's configured timeout
|
|
42
|
+
* or DEFAULT_CHECKPOINT_TIMEOUT_MS (30s).
|
|
43
|
+
*/
|
|
44
|
+
awaitCheckpoint?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Start the workflow and return as soon as Temporal acknowledges execution.
|
|
47
|
+
*
|
|
48
|
+
* Unlike awaitCheckpoint, this does not wait for any workflow progress beyond
|
|
49
|
+
* successful handoff to Temporal.
|
|
50
|
+
*/
|
|
51
|
+
startOnly?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Executes a workflow using Temporal runtime.
|
|
55
|
+
*
|
|
56
|
+
* This function:
|
|
57
|
+
* 1. Creates a WorkflowInput from the initial data
|
|
58
|
+
* 2. Calls the Temporal client to execute the workflow
|
|
59
|
+
* 3. Returns WorkflowResult with bag and optional error (never throws)
|
|
60
|
+
*
|
|
61
|
+
* ## Checkpoints:
|
|
62
|
+
*
|
|
63
|
+
* If `options.awaitCheckpoint` is specified, the function returns early when
|
|
64
|
+
* that checkpoint is reached, providing partial results while the workflow
|
|
65
|
+
* continues executing in the background. Useful for fast HTTP responses.
|
|
66
|
+
*
|
|
67
|
+
* ## Observability:
|
|
68
|
+
*
|
|
69
|
+
* Temporal workflows rely on Temporal's built-in observability (metrics, traces, logs).
|
|
70
|
+
* Activity-level observability (spans, metrics) should be added in the activity workers.
|
|
71
|
+
* For now, use Temporal UI and Prometheus metrics for workflow monitoring.
|
|
72
|
+
* Cross-span correlation is handled automatically via OpenTelemetry trace context propagation.
|
|
73
|
+
*
|
|
74
|
+
* @param wf - The workflow definition to execute
|
|
75
|
+
* @param initialData - Initial data for the workflow
|
|
76
|
+
* @param options - Temporal execution options
|
|
77
|
+
* @returns WorkflowResult with bag and optional error
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export declare function executeWorkflowTemporal<Bag extends Record<string, any>>(wf: Workflow<Bag, any, any>, initialData: Partial<Bag>, options: TemporalExecutionOptions): Promise<WorkflowResult<Bag>>;
|
|
82
|
+
/**
|
|
83
|
+
* Starts a workflow on Temporal without waiting for completion (fire-and-forget).
|
|
84
|
+
*
|
|
85
|
+
* Returns the workflowId immediately. The workflow executes in the background
|
|
86
|
+
* on Temporal workers. Use this for 202 Accepted HTTP responses.
|
|
87
|
+
*
|
|
88
|
+
* @param wf - The workflow definition to execute
|
|
89
|
+
* @param initialData - Initial data for the workflow
|
|
90
|
+
* @param options - Temporal execution options
|
|
91
|
+
* @returns The workflowId of the started workflow
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare function startWorkflowTemporal<Bag extends Record<string, any>>(wf: Workflow<Bag, any, any>, initialData: Partial<Bag>, options: Pick<TemporalExecutionOptions, "workflowId" | "clientConfig" | "versioningOverride">): Promise<{
|
|
96
|
+
workflowId: string;
|
|
97
|
+
}>;
|
|
98
|
+
//# sourceMappingURL=workflow-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../../../src/internal/async/execute/workflow-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3E,EAAE,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3B,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,EACzB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CA+H9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzE,EAAE,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3B,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,EACzB,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,YAAY,GAAG,cAAc,GAAG,oBAAoB,CAAC,GAC5F,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBjC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Workflow Execution Integration for Temporal
|
|
4
|
+
*
|
|
5
|
+
* This module provides the integration layer between the synchronous workflow API
|
|
6
|
+
* (runWorkflow) and the Temporal async execution runtime. It bridges the gap by:
|
|
7
|
+
* - Converting sync workflow definitions to Temporal inputs
|
|
8
|
+
* - Integrating with the observability system (metrics/tracing)
|
|
9
|
+
* - Managing workflow lifecycle (start/success/failure)
|
|
10
|
+
* - Supporting early returns via checkpoints
|
|
11
|
+
*
|
|
12
|
+
* This is the glue layer that makes Temporal execution transparent to users of
|
|
13
|
+
* the synchronous runWorkflow() API.
|
|
14
|
+
*
|
|
15
|
+
* @module workflow-execution
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.executeWorkflowTemporal = executeWorkflowTemporal;
|
|
19
|
+
exports.startWorkflowTemporal = startWorkflowTemporal;
|
|
20
|
+
const client_1 = require("@temporalio/client");
|
|
21
|
+
const dag_sync_workflow_1 = require("../../dag-sync-workflow");
|
|
22
|
+
const workflow_factory_1 = require("../build/workflow-factory");
|
|
23
|
+
const temporal_client_1 = require("./temporal-client");
|
|
24
|
+
/**
|
|
25
|
+
* Executes a workflow using Temporal runtime.
|
|
26
|
+
*
|
|
27
|
+
* This function:
|
|
28
|
+
* 1. Creates a WorkflowInput from the initial data
|
|
29
|
+
* 2. Calls the Temporal client to execute the workflow
|
|
30
|
+
* 3. Returns WorkflowResult with bag and optional error (never throws)
|
|
31
|
+
*
|
|
32
|
+
* ## Checkpoints:
|
|
33
|
+
*
|
|
34
|
+
* If `options.awaitCheckpoint` is specified, the function returns early when
|
|
35
|
+
* that checkpoint is reached, providing partial results while the workflow
|
|
36
|
+
* continues executing in the background. Useful for fast HTTP responses.
|
|
37
|
+
*
|
|
38
|
+
* ## Observability:
|
|
39
|
+
*
|
|
40
|
+
* Temporal workflows rely on Temporal's built-in observability (metrics, traces, logs).
|
|
41
|
+
* Activity-level observability (spans, metrics) should be added in the activity workers.
|
|
42
|
+
* For now, use Temporal UI and Prometheus metrics for workflow monitoring.
|
|
43
|
+
* Cross-span correlation is handled automatically via OpenTelemetry trace context propagation.
|
|
44
|
+
*
|
|
45
|
+
* @param wf - The workflow definition to execute
|
|
46
|
+
* @param initialData - Initial data for the workflow
|
|
47
|
+
* @param options - Temporal execution options
|
|
48
|
+
* @returns WorkflowResult with bag and optional error
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
async function executeWorkflowTemporal(wf, initialData, options) {
|
|
53
|
+
// Merge configured values with initial data (like sync path does)
|
|
54
|
+
// This ensures workflows that use .configure() work the same in both modes
|
|
55
|
+
const mergedInitialData = {
|
|
56
|
+
...initialData,
|
|
57
|
+
...(wf.configuredValues ?? {}),
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
if (options.startOnly && options.awaitCheckpoint) {
|
|
61
|
+
throw new Error("Cannot use startOnly and awaitCheckpoint together");
|
|
62
|
+
}
|
|
63
|
+
// Validate checkpoint name and resolve timeout if awaitCheckpoint is specified
|
|
64
|
+
let checkpointTimeoutMs;
|
|
65
|
+
if (options.awaitCheckpoint) {
|
|
66
|
+
const checkpoint = wf.checkpoints?.find((c) => c.name === options.awaitCheckpoint);
|
|
67
|
+
if (!checkpoint) {
|
|
68
|
+
const validNames = wf.checkpoints?.map((c) => c.name).join(", ") ?? "none";
|
|
69
|
+
throw new Error(`Unknown checkpoint "${options.awaitCheckpoint}" for workflow "${wf.name}". ` +
|
|
70
|
+
`Valid checkpoints: [${validNames}]`);
|
|
71
|
+
}
|
|
72
|
+
checkpointTimeoutMs = checkpoint.timeout ?? dag_sync_workflow_1.DEFAULT_CHECKPOINT_TIMEOUT_MS;
|
|
73
|
+
}
|
|
74
|
+
const clientConfig = options.clientConfig;
|
|
75
|
+
const workflowInput = {
|
|
76
|
+
initialData: mergedInitialData,
|
|
77
|
+
};
|
|
78
|
+
if (options.startOnly) {
|
|
79
|
+
await (0, temporal_client_1.executeWorkflow)({
|
|
80
|
+
workflowName: wf.name,
|
|
81
|
+
workflowId: options.workflowId,
|
|
82
|
+
input: workflowInput,
|
|
83
|
+
taskQueue: "workflow-tasks",
|
|
84
|
+
clientConfig,
|
|
85
|
+
});
|
|
86
|
+
return { bag: mergedInitialData, error: undefined };
|
|
87
|
+
}
|
|
88
|
+
if (options.awaitCheckpoint) {
|
|
89
|
+
// Start the workflow (don't wait for completion)
|
|
90
|
+
await (0, temporal_client_1.executeWorkflow)({
|
|
91
|
+
workflowName: wf.name,
|
|
92
|
+
workflowId: options.workflowId,
|
|
93
|
+
input: workflowInput,
|
|
94
|
+
taskQueue: "workflow-tasks",
|
|
95
|
+
clientConfig,
|
|
96
|
+
versioningOverride: options.versioningOverride,
|
|
97
|
+
});
|
|
98
|
+
// Use Temporal Update to wait for checkpoint (no polling!)
|
|
99
|
+
// The workflow's update handler blocks until the checkpoint is reached
|
|
100
|
+
const client = await (0, temporal_client_1.createTemporalClient)(clientConfig);
|
|
101
|
+
const typedHandle = client.workflow.getHandle(options.workflowId);
|
|
102
|
+
// Race the update against the configured checkpoint timeout so callers
|
|
103
|
+
// get a timely error instead of blocking indefinitely when the workflow
|
|
104
|
+
// never reaches the checkpoint (e.g. a step hangs or fails earlier).
|
|
105
|
+
const updatePromise = typedHandle.executeUpdate(workflow_factory_1.awaitCheckpointUpdate, {
|
|
106
|
+
args: [{ checkpointName: options.awaitCheckpoint }],
|
|
107
|
+
});
|
|
108
|
+
const partialBag = await new Promise((resolve, reject) => {
|
|
109
|
+
const timeoutId = setTimeout(() => {
|
|
110
|
+
reject(new Error(`Checkpoint "${options.awaitCheckpoint}" for workflow "${wf.name}" ` +
|
|
111
|
+
`timed out after ${checkpointTimeoutMs}ms`));
|
|
112
|
+
}, checkpointTimeoutMs);
|
|
113
|
+
updatePromise.then((result) => {
|
|
114
|
+
clearTimeout(timeoutId);
|
|
115
|
+
resolve(result);
|
|
116
|
+
}, (err) => {
|
|
117
|
+
clearTimeout(timeoutId);
|
|
118
|
+
reject(err);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return { bag: partialBag, error: undefined };
|
|
122
|
+
}
|
|
123
|
+
// Wait for full workflow completion (existing behavior)
|
|
124
|
+
const result = await (0, temporal_client_1.executeWorkflowAndWait)({
|
|
125
|
+
workflowName: wf.name,
|
|
126
|
+
workflowId: options.workflowId,
|
|
127
|
+
input: workflowInput,
|
|
128
|
+
taskQueue: "workflow-tasks",
|
|
129
|
+
clientConfig,
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
// Temporal throws WorkflowFailedError when a workflow exits via ApplicationFailure.
|
|
135
|
+
// We pack the bag and structured error into ApplicationFailure.details so we can
|
|
136
|
+
// reconstruct a WorkflowResult here instead of losing the partial bag state.
|
|
137
|
+
if (err instanceof client_1.WorkflowFailedError && err.cause instanceof client_1.ApplicationFailure) {
|
|
138
|
+
const detail = err.cause.details?.[0];
|
|
139
|
+
if (detail) {
|
|
140
|
+
const errorInfo = detail.error;
|
|
141
|
+
const error = errorInfo
|
|
142
|
+
? Object.assign(new Error(errorInfo.message), {
|
|
143
|
+
code: errorInfo.code,
|
|
144
|
+
type: errorInfo.type,
|
|
145
|
+
batchNumber: errorInfo.batchNumber,
|
|
146
|
+
errors: errorInfo.errors,
|
|
147
|
+
})
|
|
148
|
+
: new Error(err.message);
|
|
149
|
+
return { bag: (detail.bag ?? mergedInitialData), error };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
153
|
+
return { bag: mergedInitialData, error };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Starts a workflow on Temporal without waiting for completion (fire-and-forget).
|
|
158
|
+
*
|
|
159
|
+
* Returns the workflowId immediately. The workflow executes in the background
|
|
160
|
+
* on Temporal workers. Use this for 202 Accepted HTTP responses.
|
|
161
|
+
*
|
|
162
|
+
* @param wf - The workflow definition to execute
|
|
163
|
+
* @param initialData - Initial data for the workflow
|
|
164
|
+
* @param options - Temporal execution options
|
|
165
|
+
* @returns The workflowId of the started workflow
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
async function startWorkflowTemporal(wf, initialData, options) {
|
|
170
|
+
// Merge configured values with initial data (like sync path does)
|
|
171
|
+
const mergedInitialData = {
|
|
172
|
+
...initialData,
|
|
173
|
+
...(wf.configuredValues ?? {}),
|
|
174
|
+
};
|
|
175
|
+
const workflowInput = {
|
|
176
|
+
initialData: mergedInitialData,
|
|
177
|
+
};
|
|
178
|
+
// Use unversioned workflow name -- Temporal Worker Versioning routes to the
|
|
179
|
+
// correct worker deployment via workerDeploymentOptions.buildId, not the
|
|
180
|
+
// workflow type name.
|
|
181
|
+
await (0, temporal_client_1.executeWorkflow)({
|
|
182
|
+
workflowName: wf.name,
|
|
183
|
+
workflowId: options.workflowId,
|
|
184
|
+
input: workflowInput,
|
|
185
|
+
taskQueue: "workflow-tasks",
|
|
186
|
+
clientConfig: options.clientConfig,
|
|
187
|
+
versioningOverride: options.versioningOverride,
|
|
188
|
+
});
|
|
189
|
+
return { workflowId: options.workflowId };
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=workflow-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../../../src/internal/async/execute/workflow-execution.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAiFH,0DAmIC;AAeD,sDA4BC;AA7PD,+CAA6E;AAE7E,+DAIiC;AAGjC,gEAAkE;AAClE,uDAAkG;AAyClG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,uBAAuB,CAC3C,EAA2B,EAC3B,WAAyB,EACzB,OAAiC;IAEjC,kEAAkE;IAClE,2EAA2E;IAC3E,MAAM,iBAAiB,GAAG;QACxB,GAAG,WAAW;QACd,GAAG,CAAC,EAAE,CAAC,gBAAgB,IAAI,EAAE,CAAC;KACf,CAAC;IAElB,IAAI,CAAC;QACH,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACvE,CAAC;QAED,+EAA+E;QAC/E,IAAI,mBAAuC,CAAC;QAC5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;;GAYG;AACI,KAAK,UAAU,qBAAqB,CACzC,EAA2B,EAC3B,WAAyB,EACzB,OAA6F;IAE7F,kEAAkE;IAClE,MAAM,iBAAiB,GAAG;QACxB,GAAG,WAAW;QACd,GAAG,CAAC,EAAE,CAAC,gBAAgB,IAAI,EAAE,CAAC;KACf,CAAC;IAElB,MAAM,aAAa,GAAG;QACpB,WAAW,EAAE,iBAAiB;KAC/B,CAAC;IAEF,4EAA4E;IAC5E,yEAAyE;IACzE,sBAAsB;IACtB,MAAM,IAAA,iCAAe,EAAC;QACpB,YAAY,EAAE,EAAE,CAAC,IAAI;QACrB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,aAAa;QACpB,SAAS,EAAE,gBAAgB;QAC3B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;KAC/C,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal Task Queue Metrics Publisher
|
|
3
|
+
*
|
|
4
|
+
* Each activity worker container can poll one or more Temporal task queues and
|
|
5
|
+
* emits CloudWatch metrics used by ECS autoscaling. The two published metrics
|
|
6
|
+
* look similar at first glance because they share the same queue dimensions,
|
|
7
|
+
* but they represent different kinds of truth and therefore must be aggregated
|
|
8
|
+
* differently:
|
|
9
|
+
*
|
|
10
|
+
* 1. TaskQueueBacklogCount -- queue-level state from DescribeTaskQueue.
|
|
11
|
+
* This answers "how many activity tasks are waiting in queue X right now?"
|
|
12
|
+
* That answer belongs to the queue itself, not to any specific container.
|
|
13
|
+
* If five containers all poll "standard-tasks", they will all observe the
|
|
14
|
+
* same backlog value and all publish, for example, "12" for the same
|
|
15
|
+
* CloudWatch dimensions. Those five samples are duplicate observations of
|
|
16
|
+
* one queue, not five separate chunks of work. Consumers therefore must
|
|
17
|
+
* read backlog per queue with the Maximum statistic, which preserves the
|
|
18
|
+
* true queue backlog of 12 instead of accidentally treating it like 60.
|
|
19
|
+
* Once each queue has been reduced to its true backlog, autoscaling can sum
|
|
20
|
+
* across distinct queues to answer "how much pending work does this ECS
|
|
21
|
+
* service need to handle overall?"
|
|
22
|
+
*
|
|
23
|
+
* 2. RunningActivitiesCount -- container-level state for this process.
|
|
24
|
+
* This answers "how many activity tasks is this container executing right
|
|
25
|
+
* now?" The counter is process-wide and does not care which polled queue
|
|
26
|
+
* each activity originally came from. If one container is polling both
|
|
27
|
+
* "standard-tasks" and "heavy-tasks" and currently has 7 running
|
|
28
|
+
* activities total, this publisher emits:
|
|
29
|
+
*
|
|
30
|
+
* RunningActivitiesCount{TaskQueue="standard-tasks"} = 7
|
|
31
|
+
* RunningActivitiesCount{TaskQueue="heavy-tasks"} = 7
|
|
32
|
+
*
|
|
33
|
+
* Those are not two independent groups of 7 running tasks. They are the
|
|
34
|
+
* same process-wide total written under two queue labels so that each polled
|
|
35
|
+
* queue has a metric stream. Consumers therefore must NOT sum running count
|
|
36
|
+
* across all queue dimensions for a multi-queue worker, or that one
|
|
37
|
+
* container would be double-counted. Instead, autoscaling must choose one
|
|
38
|
+
* canonical queue dimension for the service (the primary queue) and sum
|
|
39
|
+
* RunningActivitiesCount across containers only within that single
|
|
40
|
+
* dimension. That produces the real fleet-wide in-flight activity count
|
|
41
|
+
* without inflating totals for workers that poll absorbed fallback queues.
|
|
42
|
+
*/
|
|
43
|
+
import { CloudWatchClient } from "@aws-sdk/client-cloudwatch";
|
|
44
|
+
import type { NativeConnection } from "@temporalio/worker";
|
|
45
|
+
import type { ComposerLogger } from "../../types";
|
|
46
|
+
export interface TaskQueueMetricsConfig {
|
|
47
|
+
connection: NativeConnection;
|
|
48
|
+
taskQueues: string[];
|
|
49
|
+
temporalNamespace: string;
|
|
50
|
+
logger: ComposerLogger;
|
|
51
|
+
/** Environment name used as a CloudWatch dimension to avoid collisions. */
|
|
52
|
+
environmentName?: string;
|
|
53
|
+
/** CloudWatch publishing interval in ms. Defaults to 60000 (60s). */
|
|
54
|
+
pollIntervalMs?: number;
|
|
55
|
+
/** CloudWatch metric namespace. Defaults to "Composer". */
|
|
56
|
+
cloudWatchNamespace?: string;
|
|
57
|
+
/** Injected for testing. Defaults to a real CloudWatchClient. */
|
|
58
|
+
cloudWatchClient?: CloudWatchClient;
|
|
59
|
+
}
|
|
60
|
+
export interface TaskQueueMetricsHandle {
|
|
61
|
+
/** Stop the polling loop and clean up. */
|
|
62
|
+
stop: () => void;
|
|
63
|
+
/** Report that an activity started on this container. */
|
|
64
|
+
activityStarted: () => void;
|
|
65
|
+
/** Report that an activity finished on this container. */
|
|
66
|
+
activityFinished: () => void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Starts a background polling loop that publishes task queue metrics to CloudWatch.
|
|
70
|
+
*
|
|
71
|
+
* Returns a handle to stop the loop and to track running activity count.
|
|
72
|
+
*/
|
|
73
|
+
export declare function startTaskQueueMetrics(config: TaskQueueMetricsConfig): TaskQueueMetricsHandle;
|
|
74
|
+
//# sourceMappingURL=task-queue-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-queue-metrics.d.ts","sourceRoot":"","sources":["../../../../src/internal/async/metrics/task-queue-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EACL,gBAAgB,EAIjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAUlD,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,cAAc,CAAC;IACvB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,yDAAyD;IACzD,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,0DAA0D;IAC1D,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,CAyH5F"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Temporal Task Queue Metrics Publisher
|
|
4
|
+
*
|
|
5
|
+
* Each activity worker container can poll one or more Temporal task queues and
|
|
6
|
+
* emits CloudWatch metrics used by ECS autoscaling. The two published metrics
|
|
7
|
+
* look similar at first glance because they share the same queue dimensions,
|
|
8
|
+
* but they represent different kinds of truth and therefore must be aggregated
|
|
9
|
+
* differently:
|
|
10
|
+
*
|
|
11
|
+
* 1. TaskQueueBacklogCount -- queue-level state from DescribeTaskQueue.
|
|
12
|
+
* This answers "how many activity tasks are waiting in queue X right now?"
|
|
13
|
+
* That answer belongs to the queue itself, not to any specific container.
|
|
14
|
+
* If five containers all poll "standard-tasks", they will all observe the
|
|
15
|
+
* same backlog value and all publish, for example, "12" for the same
|
|
16
|
+
* CloudWatch dimensions. Those five samples are duplicate observations of
|
|
17
|
+
* one queue, not five separate chunks of work. Consumers therefore must
|
|
18
|
+
* read backlog per queue with the Maximum statistic, which preserves the
|
|
19
|
+
* true queue backlog of 12 instead of accidentally treating it like 60.
|
|
20
|
+
* Once each queue has been reduced to its true backlog, autoscaling can sum
|
|
21
|
+
* across distinct queues to answer "how much pending work does this ECS
|
|
22
|
+
* service need to handle overall?"
|
|
23
|
+
*
|
|
24
|
+
* 2. RunningActivitiesCount -- container-level state for this process.
|
|
25
|
+
* This answers "how many activity tasks is this container executing right
|
|
26
|
+
* now?" The counter is process-wide and does not care which polled queue
|
|
27
|
+
* each activity originally came from. If one container is polling both
|
|
28
|
+
* "standard-tasks" and "heavy-tasks" and currently has 7 running
|
|
29
|
+
* activities total, this publisher emits:
|
|
30
|
+
*
|
|
31
|
+
* RunningActivitiesCount{TaskQueue="standard-tasks"} = 7
|
|
32
|
+
* RunningActivitiesCount{TaskQueue="heavy-tasks"} = 7
|
|
33
|
+
*
|
|
34
|
+
* Those are not two independent groups of 7 running tasks. They are the
|
|
35
|
+
* same process-wide total written under two queue labels so that each polled
|
|
36
|
+
* queue has a metric stream. Consumers therefore must NOT sum running count
|
|
37
|
+
* across all queue dimensions for a multi-queue worker, or that one
|
|
38
|
+
* container would be double-counted. Instead, autoscaling must choose one
|
|
39
|
+
* canonical queue dimension for the service (the primary queue) and sum
|
|
40
|
+
* RunningActivitiesCount across containers only within that single
|
|
41
|
+
* dimension. That produces the real fleet-wide in-flight activity count
|
|
42
|
+
* without inflating totals for workers that poll absorbed fallback queues.
|
|
43
|
+
*/
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.startTaskQueueMetrics = startTaskQueueMetrics;
|
|
46
|
+
const client_cloudwatch_1 = require("@aws-sdk/client-cloudwatch");
|
|
47
|
+
const DEFAULT_CLOUDWATCH_NAMESPACE = "Composer";
|
|
48
|
+
const DEFAULT_POLL_INTERVAL_MS = 60_000;
|
|
49
|
+
function getNextPublishTimestampMs(nowMs, intervalMs) {
|
|
50
|
+
const remainder = nowMs % intervalMs;
|
|
51
|
+
return remainder === 0 ? nowMs + intervalMs : nowMs + (intervalMs - remainder);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Starts a background polling loop that publishes task queue metrics to CloudWatch.
|
|
55
|
+
*
|
|
56
|
+
* Returns a handle to stop the loop and to track running activity count.
|
|
57
|
+
*/
|
|
58
|
+
function startTaskQueueMetrics(config) {
|
|
59
|
+
const { connection, taskQueues, temporalNamespace, environmentName = process.env.ENVIRONMENT_NAME ?? "unknown", logger, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, cloudWatchNamespace = DEFAULT_CLOUDWATCH_NAMESPACE, cloudWatchClient = new client_cloudwatch_1.CloudWatchClient({}), } = config;
|
|
60
|
+
let runningActivities = 0;
|
|
61
|
+
let stopped = false;
|
|
62
|
+
let timer;
|
|
63
|
+
let nextPublishTimestampMs = getNextPublishTimestampMs(Date.now(), pollIntervalMs);
|
|
64
|
+
const scheduleNextPublish = () => {
|
|
65
|
+
if (stopped)
|
|
66
|
+
return;
|
|
67
|
+
const nowMs = Date.now();
|
|
68
|
+
while (nextPublishTimestampMs <= nowMs) {
|
|
69
|
+
nextPublishTimestampMs += pollIntervalMs;
|
|
70
|
+
}
|
|
71
|
+
timer = setTimeout(() => {
|
|
72
|
+
const publishTimestampMs = nextPublishTimestampMs;
|
|
73
|
+
nextPublishTimestampMs += pollIntervalMs;
|
|
74
|
+
void publishMetrics(new Date(publishTimestampMs));
|
|
75
|
+
}, nextPublishTimestampMs - nowMs);
|
|
76
|
+
timer.unref();
|
|
77
|
+
};
|
|
78
|
+
const publishMetrics = async (timestamp) => {
|
|
79
|
+
if (stopped)
|
|
80
|
+
return;
|
|
81
|
+
try {
|
|
82
|
+
const metricData = [];
|
|
83
|
+
for (const taskQueue of taskQueues) {
|
|
84
|
+
const dimensions = [
|
|
85
|
+
{ Name: "TaskQueue", Value: taskQueue },
|
|
86
|
+
{ Name: "TemporalNamespace", Value: temporalNamespace },
|
|
87
|
+
{ Name: "Environment", Value: environmentName },
|
|
88
|
+
];
|
|
89
|
+
let backlogCount = 0;
|
|
90
|
+
try {
|
|
91
|
+
const response = await connection.workflowService.describeTaskQueue({
|
|
92
|
+
namespace: temporalNamespace,
|
|
93
|
+
taskQueue: { name: taskQueue },
|
|
94
|
+
taskQueueType: 2,
|
|
95
|
+
reportStats: true,
|
|
96
|
+
});
|
|
97
|
+
backlogCount = Number(response.stats?.approximateBacklogCount ?? 0);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger.warn("Failed to describe task queue", {
|
|
101
|
+
taskQueue,
|
|
102
|
+
error: error instanceof Error ? error.message : String(error),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
metricData.push({
|
|
106
|
+
MetricName: "TaskQueueBacklogCount",
|
|
107
|
+
Dimensions: dimensions,
|
|
108
|
+
Value: backlogCount,
|
|
109
|
+
Unit: client_cloudwatch_1.StandardUnit.Count,
|
|
110
|
+
Timestamp: timestamp,
|
|
111
|
+
}, {
|
|
112
|
+
MetricName: "RunningActivitiesCount",
|
|
113
|
+
Dimensions: dimensions,
|
|
114
|
+
Value: runningActivities,
|
|
115
|
+
Unit: client_cloudwatch_1.StandardUnit.Count,
|
|
116
|
+
Timestamp: timestamp,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (metricData.length > 0) {
|
|
120
|
+
await cloudWatchClient.send(new client_cloudwatch_1.PutMetricDataCommand({
|
|
121
|
+
Namespace: cloudWatchNamespace,
|
|
122
|
+
MetricData: metricData,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
logger.warn("Failed to publish task queue metrics", {
|
|
128
|
+
error: error instanceof Error ? error.message : String(error),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
scheduleNextPublish();
|
|
132
|
+
};
|
|
133
|
+
scheduleNextPublish();
|
|
134
|
+
logger.info("Task queue metrics poller started", {
|
|
135
|
+
taskQueues,
|
|
136
|
+
temporalNamespace,
|
|
137
|
+
pollIntervalMs,
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
stop: () => {
|
|
141
|
+
stopped = true;
|
|
142
|
+
if (timer) {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
}
|
|
145
|
+
logger.info("Task queue metrics poller stopped");
|
|
146
|
+
},
|
|
147
|
+
activityStarted: () => {
|
|
148
|
+
runningActivities++;
|
|
149
|
+
},
|
|
150
|
+
activityFinished: () => {
|
|
151
|
+
runningActivities = Math.max(0, runningActivities - 1);
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=task-queue-metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-queue-metrics.js","sourceRoot":"","sources":["../../../../src/internal/async/metrics/task-queue-metrics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;AAgDH,sDAyHC;AAvKD,kEAKoC;AAIpC,MAAM,4BAA4B,GAAG,UAAU,CAAC;AAChD,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAExC,SAAS,yBAAyB,CAAC,KAAa,EAAE,UAAkB;IAClE,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC;IACrC,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;AACjF,CAAC;AA0BD;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,MAA8B;IAClE,MAAM,EACJ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,EAC3D,MAAM,EACN,cAAc,GAAG,wBAAwB,EACzC,mBAAmB,GAAG,4BAA4B,EAClD,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,EAAE,CAAC,GAC5C,GAAG,MAAM,CAAC;IAEX,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IAC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IACxB,CAAC,CAAC;IAEF,mBAAmB,EAAE,CAAC;IAEtB,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;QAC/C,UAAU;QACV,iBAAiB;QACjB,cAAc;KACf,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,GAAG,EAAE;YACT,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,KAAK,EAAE,CAAC;gBACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACnD,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,iBAAiB,EAAE,CAAC;QACtB,CAAC;QACD,gBAAgB,EAAE,GAAG,EAAE;YACrB,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,GAAG,CAAC,CAAC,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal Activity Worker
|
|
3
|
+
*
|
|
4
|
+
* Registers and executes step business logic as Temporal activities.
|
|
5
|
+
* Accepts workflow definitions declaratively and extracts steps from them.
|
|
6
|
+
*
|
|
7
|
+
* ## Activity Worker Responsibilities:
|
|
8
|
+
* - Connect to Temporal Server
|
|
9
|
+
* - Extract step definitions from provided workflow objects
|
|
10
|
+
* - Create Temporal activities from steps
|
|
11
|
+
* - Create wrapper activities for error handlers and FanOut operations
|
|
12
|
+
* - Register activities with appropriate task queues (fast/standard/heavy)
|
|
13
|
+
* - Execute business logic directly (steps handle their own dependencies)
|
|
14
|
+
*
|
|
15
|
+
* ## What Activities CAN Do (unlike workflows):
|
|
16
|
+
* - Access Node.js APIs (fs, http, process, etc.)
|
|
17
|
+
* - Make database queries
|
|
18
|
+
* - Call external APIs
|
|
19
|
+
* - Use non-deterministic functions
|
|
20
|
+
* - Import and execute business logic
|
|
21
|
+
*
|
|
22
|
+
* ## Step Execution Model:
|
|
23
|
+
* Steps are pure business logic that receive only their declared inputs (bag fields).
|
|
24
|
+
* Steps obtain their own dependencies (e.g., IxDbConnection.getInstance()).
|
|
25
|
+
* The workflow engine handles all observability automatically.
|
|
26
|
+
*
|
|
27
|
+
* @module activity-worker
|
|
28
|
+
*/
|
|
29
|
+
import { NativeConnection, Worker } from "@temporalio/worker";
|
|
30
|
+
import type { StepContextProvider } from "../../context-provider";
|
|
31
|
+
import type { Workflow } from "../../dag-sync-workflow";
|
|
32
|
+
import type { ComposerLogger } from "../../types";
|
|
33
|
+
import { type TaskQueueMetricsHandle } from "../metrics/task-queue-metrics";
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the Activity Worker.
|
|
36
|
+
* All fields are required - callers must provide complete configuration.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam TContext - The context type provided to steps
|
|
39
|
+
*/
|
|
40
|
+
export interface ActivityWorkerConfig<TContext = unknown> {
|
|
41
|
+
/**
|
|
42
|
+
* Temporal Server address (e.g., "localhost:7233" for local dev)
|
|
43
|
+
*/
|
|
44
|
+
serverAddress: string;
|
|
45
|
+
/**
|
|
46
|
+
* Temporal namespace to connect to
|
|
47
|
+
*/
|
|
48
|
+
namespace: string;
|
|
49
|
+
/**
|
|
50
|
+
* Deployment series name for Worker Versioning (e.g., "orders-service-activities").
|
|
51
|
+
* Derived from the service name via getDeploymentSeriesNames().
|
|
52
|
+
*/
|
|
53
|
+
deploymentSeriesName: string;
|
|
54
|
+
/**
|
|
55
|
+
* Build identifier for Worker Versioning (typically git commit SHA).
|
|
56
|
+
* When set, workers register with this buildId for version-aware routing.
|
|
57
|
+
* When unset, Worker Versioning is disabled.
|
|
58
|
+
*/
|
|
59
|
+
buildId?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Task queues to listen on for activity tasks.
|
|
62
|
+
* Activities are routed to queues based on their workerProfile.
|
|
63
|
+
*/
|
|
64
|
+
taskQueues: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Maximum number of concurrent activity executions per queue
|
|
67
|
+
*/
|
|
68
|
+
maxConcurrentActivityTaskExecutions: number;
|
|
69
|
+
/**
|
|
70
|
+
* Context provider for step execution.
|
|
71
|
+
* If provided, beforeStep/afterStep hooks will be called for each activity.
|
|
72
|
+
*/
|
|
73
|
+
contextProvider?: StepContextProvider<TContext>;
|
|
74
|
+
/**
|
|
75
|
+
* Workflow definitions to register.
|
|
76
|
+
* Steps are extracted from each workflow's .steps array.
|
|
77
|
+
* Error handlers and FanOut wrappers are derived from the workflows.
|
|
78
|
+
*/
|
|
79
|
+
workflows: Workflow<any, any, any>[];
|
|
80
|
+
/**
|
|
81
|
+
* Logger for worker lifecycle and activity execution messages.
|
|
82
|
+
* If not provided, defaults to the console-based defaultLogger.
|
|
83
|
+
*/
|
|
84
|
+
logger?: ComposerLogger;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates Temporal Activity Workers with automatic connection management.
|
|
88
|
+
*
|
|
89
|
+
* Extracts steps from the provided workflow definitions, creates activity
|
|
90
|
+
* functions, and registers them with Temporal workers for the specified
|
|
91
|
+
* task queues.
|
|
92
|
+
*
|
|
93
|
+
* @param config - Worker configuration
|
|
94
|
+
* @returns Object containing workers array and the created connection
|
|
95
|
+
*/
|
|
96
|
+
export declare function createActivityWorkers<TContext = unknown>(config: ActivityWorkerConfig<TContext>): Promise<{
|
|
97
|
+
workers: Worker[];
|
|
98
|
+
connection: NativeConnection;
|
|
99
|
+
metricsHandle?: TaskQueueMetricsHandle;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Starts Activity Workers and runs them until interrupted.
|
|
103
|
+
*
|
|
104
|
+
* Creates a Temporal connection, initializes workers with loaded step implementations,
|
|
105
|
+
* and handles graceful shutdown on SIGINT/SIGTERM. The connection is automatically
|
|
106
|
+
* managed and closed on shutdown.
|
|
107
|
+
*
|
|
108
|
+
* @param config - Worker configuration
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Run activity workers (blocks until interrupted)
|
|
113
|
+
* await runActivityWorkers({
|
|
114
|
+
* serverAddress: "localhost:7233",
|
|
115
|
+
* namespace: "default",
|
|
116
|
+
* taskQueues: ["workflow-tasks"],
|
|
117
|
+
* maxConcurrentActivityTaskExecutions: 10,
|
|
118
|
+
* workflows: [myWorkflow],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function runActivityWorkers<TContext = unknown>(config: ActivityWorkerConfig<TContext>): Promise<void>;
|
|
123
|
+
//# sourceMappingURL=activity-worker.d.ts.map
|