@btravstack/temporal-worker 0.48.1 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +15 -3
- package/dist/schedule.d.mts +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -221,6 +221,8 @@ optional peers. See
|
|
|
221
221
|
|
|
222
222
|
## Options
|
|
223
223
|
|
|
224
|
+
- `taskQueue`: pins `TEMPORAL_TASK_QUEUE`, defaulting to the contract queue; see the [reference](https://btravstack.github.io/btravstack/reference/temporal-worker).
|
|
225
|
+
|
|
224
226
|
`TemporalModule(name)({...})` takes the starter's options plus `activities`
|
|
225
227
|
and the module lists (`imports`, `provides`, `exports`, `needs`). It is the
|
|
226
228
|
only way to compose the starter, which is not exported:
|
package/dist/index.d.mts
CHANGED
|
@@ -141,6 +141,7 @@ declare const TemporalConfig_base: import("@btravstack/di").PortClass<"TemporalC
|
|
|
141
141
|
export declare class TemporalConfig extends TemporalConfig_base<{
|
|
142
142
|
readonly address: string;
|
|
143
143
|
readonly namespace: string;
|
|
144
|
+
readonly taskQueue: string;
|
|
144
145
|
/** Temporal's `shutdownGraceTime`, in milliseconds. */
|
|
145
146
|
readonly gracePeriodMs: number;
|
|
146
147
|
/** Temporal's `shutdownForceTime`, in milliseconds. */
|
|
@@ -192,6 +193,8 @@ type TemporalTuning<Unit extends AnyUnitModule | undefined = undefined, Converte
|
|
|
192
193
|
readonly address?: string;
|
|
193
194
|
/** Pins `TemporalConfig.namespace` instead of reading `TEMPORAL_NAMESPACE`. */
|
|
194
195
|
readonly namespace?: string;
|
|
196
|
+
/** Physical polling queue, independent of the logical contract and DI identities. Pins TEMPORAL_TASK_QUEUE. */
|
|
197
|
+
readonly taskQueue?: string;
|
|
195
198
|
/**
|
|
196
199
|
* Pins `TemporalConfig.forceAfterMs` instead of reading
|
|
197
200
|
* `TEMPORAL_FORCE_AFTER_MS` (default `15_000`) — Temporal's
|
|
@@ -245,7 +248,7 @@ type TemporalOptions<C extends ContractDefinition, Unit extends AnyUnitModule |
|
|
|
245
248
|
//#endregion
|
|
246
249
|
//#region src/temporal-module.d.ts
|
|
247
250
|
/** The starter's own module, as the sugar adds it to the application's imports. */
|
|
248
|
-
type TemporalStarter<C extends ContractDefinition, Unit extends AnyUnitModule | undefined, Converter extends DataConverterPort> = Module<TemporalRuntime | TemporalConfig | TemporalConnection, ConfigInvalid | TemporalUnreachable, EnvReading<never, "TEMPORAL_ADDRESS" | "TEMPORAL_NAMESPACE" | "TEMPORAL_GRACE_PERIOD_MS" | "TEMPORAL_FORCE_AFTER_MS"> | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit> | InstanceType<Converter>>;
|
|
251
|
+
type TemporalStarter<C extends ContractDefinition, Unit extends AnyUnitModule | undefined, Converter extends DataConverterPort> = Module<TemporalRuntime | TemporalConfig | TemporalConnection, ConfigInvalid | TemporalUnreachable, EnvReading<never, "TEMPORAL_ADDRESS" | "TEMPORAL_NAMESPACE" | "TEMPORAL_TASK_QUEUE" | "TEMPORAL_GRACE_PERIOD_MS" | "TEMPORAL_FORCE_AFTER_MS"> | Scope | ActivitiesInstanceOf<C> | UnitNeedsOf$1<Unit> | InstanceType<Converter>>;
|
|
249
252
|
/** The application's imports plus the starter — the tuple `Module(name)` is handed. */
|
|
250
253
|
type Imports<I extends readonly AnyModule[], C extends ContractDefinition, Unit extends AnyUnitModule | undefined, Converter extends DataConverterPort> = readonly [...I, TemporalStarter<C, Unit, Converter>];
|
|
251
254
|
/** The activities provider plus the application's own — the tuple `Module(name)` is handed. */
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Observers, RuntimePort, RuntimeStartFailed, composeByPrefix, dispatchUnit, infrastructureExports, mintPiece, noObserverMember, releasedBy, withUnitRecord } from "@btravstack/core";
|
|
2
2
|
import { Module, Port, Provider } from "@btravstack/di";
|
|
3
|
-
import { Config, Env } from "@btravstack/config";
|
|
3
|
+
import { Config, ConfigFieldInvalid, Env } from "@btravstack/config";
|
|
4
4
|
import { declareActivitiesHandler } from "@temporal-contract/worker/activity";
|
|
5
5
|
import { msToNumber } from "@temporalio/common";
|
|
6
6
|
import { NativeConnection, Worker } from "@temporalio/worker";
|
|
7
7
|
import { Ok, OkAsync, TaggedError, fromPromise, fromSafePromise, fromThrowable } from "unthrown";
|
|
8
8
|
import { activityInfo } from "@temporalio/activity";
|
|
9
|
+
import { defineContractBinding } from "@temporal-contract/contract";
|
|
9
10
|
//#region src/unit.ts
|
|
10
11
|
/**
|
|
11
12
|
* One entry of the activities record — a contract-global activity's own
|
|
@@ -154,6 +155,17 @@ const metaFor = () => {
|
|
|
154
155
|
};
|
|
155
156
|
};
|
|
156
157
|
//#endregion
|
|
158
|
+
//#region src/task-queue.ts
|
|
159
|
+
const taskQueueField = (contract) => {
|
|
160
|
+
const field = Config.string("TEMPORAL_TASK_QUEUE", { default: contract.taskQueue });
|
|
161
|
+
const check = (taskQueue) => fromThrowable(() => defineContractBinding(contract, { taskQueue }).taskQueue, (cause) => new ConfigFieldInvalid({ reason: String(cause) }))();
|
|
162
|
+
return {
|
|
163
|
+
variable: field.variable,
|
|
164
|
+
parse: (raw) => field.parse(raw).flatMap(check),
|
|
165
|
+
check
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
157
169
|
//#region src/temporal-runtime.ts
|
|
158
170
|
/**
|
|
159
171
|
* Where the Temporal service is, as a service: the starter binds it from the
|
|
@@ -214,6 +226,7 @@ const temporal = (options) => {
|
|
|
214
226
|
const config = Config.provider(TemporalConfig)(Config.object({
|
|
215
227
|
address: Config.pinned(address, Config.string("TEMPORAL_ADDRESS", { default: "127.0.0.1:7233" })),
|
|
216
228
|
namespace: Config.pinned(namespace, Config.string("TEMPORAL_NAMESPACE", { default: "default" })),
|
|
229
|
+
taskQueue: Config.pinned(options.taskQueue, taskQueueField(options.contract)),
|
|
217
230
|
gracePeriodMs: Config.pinned(durationMs(options.gracePeriod), Config.integer("TEMPORAL_GRACE_PERIOD_MS", {
|
|
218
231
|
default: DEFAULT_GRACE_MS,
|
|
219
232
|
min: 0
|
|
@@ -269,8 +282,7 @@ const startFailed = (cause) => new RuntimeStartFailed({
|
|
|
269
282
|
});
|
|
270
283
|
const heldByWorker = (cause) => cause instanceof Error && cause.name === "IllegalStateError";
|
|
271
284
|
const createWorker = (host, connection, config, activities, options, observers, dataConverter) => {
|
|
272
|
-
const { taskQueue } =
|
|
273
|
-
const { namespace } = config;
|
|
285
|
+
const { namespace, taskQueue } = config;
|
|
274
286
|
return fromThrowable(() => declareActivitiesHandler({
|
|
275
287
|
contract: options.contract,
|
|
276
288
|
middleware: activityUnits(host, observers, (key) => forkOf(activities[key]) ?? options.unit?.activity),
|
package/dist/schedule.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncResult } from "unthrown";
|
|
2
|
-
import { ScheduleNotFoundError, TypedScheduleClient, TypedScheduleCreateOptions, WorkflowValidationError } from "@temporal-contract/client";
|
|
3
2
|
import { ContractDefinition } from "@temporal-contract/contract";
|
|
3
|
+
import { ScheduleNotFoundError, TypedScheduleClient, TypedScheduleCreateOptions, WorkflowValidationError } from "@temporal-contract/client";
|
|
4
4
|
//#region src/schedule.d.ts
|
|
5
5
|
/** Whether the schedule had to be created, or was already there and had its spec reconciled. */
|
|
6
6
|
export type ScheduleOutcome = "created" | "updated";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btravstack/temporal-worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "The Temporal worker runtime for @btravstack/core: one unit per activity attempt, and a drain that honours the kernel's deadline",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graceful-shutdown",
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@btravstack/config": "0.
|
|
56
|
-
"@btravstack/core": "0.
|
|
57
|
-
"@btravstack/di": "0.
|
|
55
|
+
"@btravstack/config": "0.49.0",
|
|
56
|
+
"@btravstack/core": "0.49.0",
|
|
57
|
+
"@btravstack/di": "0.49.0",
|
|
58
58
|
"@btravstack/internal-test-infra": "0.0.0",
|
|
59
|
-
"@btravstack/testing": "0.
|
|
59
|
+
"@btravstack/testing": "0.49.0",
|
|
60
60
|
"@btravstack/tsconfig": "0.4.0",
|
|
61
|
-
"@temporal-contract/client": "8.0.0-beta.
|
|
62
|
-
"@temporal-contract/contract": "8.0.0-beta.
|
|
63
|
-
"@temporal-contract/worker": "8.0.0-beta.
|
|
61
|
+
"@temporal-contract/client": "8.0.0-beta.15",
|
|
62
|
+
"@temporal-contract/contract": "8.0.0-beta.15",
|
|
63
|
+
"@temporal-contract/worker": "8.0.0-beta.15",
|
|
64
64
|
"@temporalio/activity": "1.24.0",
|
|
65
65
|
"@temporalio/client": "1.24.0",
|
|
66
66
|
"@temporalio/common": "1.24.0",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"zod": "4.6.7"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@btravstack/config": "^0.
|
|
82
|
-
"@btravstack/core": "^0.
|
|
83
|
-
"@btravstack/di": "^0.
|
|
84
|
-
"@temporal-contract/client": "^8.0.0-beta.
|
|
85
|
-
"@temporal-contract/contract": "^8.0.0-beta.
|
|
86
|
-
"@temporal-contract/worker": "^8.0.0-beta.
|
|
81
|
+
"@btravstack/config": "^0.49.0",
|
|
82
|
+
"@btravstack/core": "^0.49.0",
|
|
83
|
+
"@btravstack/di": "^0.49.0",
|
|
84
|
+
"@temporal-contract/client": "^8.0.0-beta.15",
|
|
85
|
+
"@temporal-contract/contract": "^8.0.0-beta.15",
|
|
86
|
+
"@temporal-contract/worker": "^8.0.0-beta.15",
|
|
87
87
|
"@temporalio/activity": "^1.24.0",
|
|
88
88
|
"@temporalio/common": "^1.24.0",
|
|
89
89
|
"@temporalio/worker": "^1.24.0",
|