@hatchet-dev/typescript-sdk 1.29.3 → 1.30.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/clients/dispatcher/action-listener.d.ts +1 -1
- package/clients/dispatcher/action-listener.js +6 -0
- package/clients/listeners/durable-listener/durable-listener-client.d.ts +6 -1
- package/clients/listeners/durable-listener/durable-listener-client.js +124 -37
- package/clients/rest/generated/Api.d.ts +6 -1
- package/clients/rest/generated/Api.js +1 -1
- package/clients/rest/generated/data-contracts.d.ts +9 -1
- package/clients/rest/generated/data-contracts.js +1 -0
- package/legacy/workflow.d.ts +4 -4
- package/legacy/workflow.js +1 -1
- package/package.json +1 -1
- package/protoc/v1/workflows.d.ts +17 -0
- package/protoc/v1/workflows.js +74 -2
- package/v1/client/worker/context.d.ts +2 -0
- package/v1/client/worker/context.js +26 -8
- package/v1/client/worker/eviction/eviction-manager.d.ts +1 -1
- package/v1/client/worker/eviction/eviction-manager.js +12 -5
- package/v1/client/worker/worker-internal.d.ts +2 -1
- package/v1/client/worker/worker-internal.js +52 -25
- package/v1/embedded.d.ts +36 -2
- package/v1/embedded.js +35 -8
- package/v1/examples/concurrency_cancel_queued_except_newest/workflow.d.ts +9 -0
- package/v1/examples/concurrency_cancel_queued_except_newest/workflow.js +47 -0
- package/v1/examples/concurrency_cancel_queued_except_oldest/workflow.d.ts +9 -0
- package/v1/examples/concurrency_cancel_queued_except_oldest/workflow.js +47 -0
- package/v1/examples/durable_callback_ordering/workflow.d.ts +42 -0
- package/v1/examples/durable_callback_ordering/workflow.js +95 -0
- package/v1/examples/durable_eviction/workflow.d.ts +5 -0
- package/v1/examples/durable_eviction/workflow.js +15 -1
- package/v1/examples/e2e-worker.js +99 -90
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.callbackOrderingRoot = exports.callbackOrderingMid = exports.callbackOrderingLeaf = exports.ROOT_DEFAULTS = void 0;
|
|
16
|
+
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
18
|
+
const WORKFLOW_PREFIX = 'durable-callback-ordering';
|
|
19
|
+
const EVICTION_POLICY = {
|
|
20
|
+
ttl: 250,
|
|
21
|
+
allowCapacityEviction: true,
|
|
22
|
+
priority: 0,
|
|
23
|
+
};
|
|
24
|
+
exports.ROOT_DEFAULTS = {
|
|
25
|
+
durables: 4,
|
|
26
|
+
branches: 8,
|
|
27
|
+
childDelayMs: 1500,
|
|
28
|
+
delayStepMs: 3,
|
|
29
|
+
};
|
|
30
|
+
exports.callbackOrderingLeaf = hatchet_client_1.hatchet.task({
|
|
31
|
+
name: `${WORKFLOW_PREFIX}-leaf`,
|
|
32
|
+
executionTimeout: '1m',
|
|
33
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
yield (0, sleep_1.default)(input.delayMs);
|
|
35
|
+
return { mid: input.mid, branch: input.branch, generation: input.generation };
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
exports.callbackOrderingMid = hatchet_client_1.hatchet.durableTask({
|
|
39
|
+
name: `${WORKFLOW_PREFIX}-mid`,
|
|
40
|
+
executionTimeout: '5m',
|
|
41
|
+
retries: 0,
|
|
42
|
+
evictionPolicy: EVICTION_POLICY,
|
|
43
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
// Staggered first-generation children complete out of spawn order, so each
|
|
45
|
+
// branch's second-generation spawn is emitted in completion order. Replays
|
|
46
|
+
// after eviction must re-deliver those completions in the recorded order or
|
|
47
|
+
// the re-emitted spawn sequence diverges from the event log.
|
|
48
|
+
const branch = (branchIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const firstDelayMs = input.childDelayMs + (input.branches - branchIndex - 1) * input.delayStepMs;
|
|
50
|
+
const first = yield exports.callbackOrderingLeaf.run({
|
|
51
|
+
mid: input.mid,
|
|
52
|
+
branch: branchIndex,
|
|
53
|
+
delayMs: firstDelayMs,
|
|
54
|
+
generation: 1,
|
|
55
|
+
});
|
|
56
|
+
const second = yield exports.callbackOrderingLeaf.run({
|
|
57
|
+
mid: input.mid,
|
|
58
|
+
branch: first.branch,
|
|
59
|
+
delayMs: input.childDelayMs,
|
|
60
|
+
generation: 2,
|
|
61
|
+
});
|
|
62
|
+
return second.branch;
|
|
63
|
+
});
|
|
64
|
+
const completed = yield Promise.all(Array.from({ length: input.branches }, (_, branchIndex) => branch(branchIndex)));
|
|
65
|
+
return {
|
|
66
|
+
mid: input.mid,
|
|
67
|
+
completedBranches: completed,
|
|
68
|
+
invocationCount: ctx.invocationCount,
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
exports.callbackOrderingRoot = hatchet_client_1.hatchet.durableTask({
|
|
73
|
+
name: `${WORKFLOW_PREFIX}-root`,
|
|
74
|
+
executionTimeout: '10m',
|
|
75
|
+
retries: 0,
|
|
76
|
+
evictionPolicy: EVICTION_POLICY,
|
|
77
|
+
fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
var _a;
|
|
79
|
+
const durables = (_a = input.durables) !== null && _a !== void 0 ? _a : exports.ROOT_DEFAULTS.durables;
|
|
80
|
+
const results = yield Promise.all(Array.from({ length: durables }, (_, midIndex) => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
return exports.callbackOrderingMid.run({
|
|
83
|
+
mid: midIndex,
|
|
84
|
+
branches: (_a = input.branches) !== null && _a !== void 0 ? _a : exports.ROOT_DEFAULTS.branches,
|
|
85
|
+
childDelayMs: (_b = input.childDelayMs) !== null && _b !== void 0 ? _b : exports.ROOT_DEFAULTS.childDelayMs,
|
|
86
|
+
delayStepMs: (_c = input.delayStepMs) !== null && _c !== void 0 ? _c : exports.ROOT_DEFAULTS.delayStepMs,
|
|
87
|
+
});
|
|
88
|
+
}));
|
|
89
|
+
return {
|
|
90
|
+
rootInvocationCount: ctx.invocationCount,
|
|
91
|
+
midInvocationCounts: results.map((item) => item.invocationCount),
|
|
92
|
+
completedMids: results.map((item) => item.mid),
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
@@ -13,6 +13,11 @@ export declare const evictableSleepForGracefulTermination: import("../..").TaskW
|
|
|
13
13
|
export declare const evictableWaitForEvent: import("../..").TaskWorkflowDeclaration<import("../..").JsonObject, {
|
|
14
14
|
status: string;
|
|
15
15
|
}, {}, {}, {}, {}>;
|
|
16
|
+
export declare const MEMO_EVENT_KEY = "durable-eviction:memo-event";
|
|
17
|
+
export declare const evictableMemoThenWaitForEvent: import("../..").TaskWorkflowDeclaration<import("../..").JsonObject, {
|
|
18
|
+
status: string;
|
|
19
|
+
memoizedNow: string;
|
|
20
|
+
}, {}, {}, {}, {}>;
|
|
16
21
|
export declare const evictableChildSpawn: import("../..").TaskWorkflowDeclaration<import("../..").JsonObject, {
|
|
17
22
|
child: {
|
|
18
23
|
child_status: string;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.nonEvictableSleep = exports.capacityEvictableSleep = exports.CAPACITY_SLEEP_SECONDS = exports.evictableChildBulkSpawn = exports.bulkChildTask = exports.multipleEviction = exports.evictableChildSpawn = exports.evictableWaitForEvent = exports.evictableSleepForGracefulTermination = exports.evictableSleep = exports.childTask = exports.EVENT_KEY = exports.LONG_SLEEP_SECONDS = exports.EVICTION_TTL_SECONDS = void 0;
|
|
15
|
+
exports.nonEvictableSleep = exports.capacityEvictableSleep = exports.CAPACITY_SLEEP_SECONDS = exports.evictableChildBulkSpawn = exports.bulkChildTask = exports.multipleEviction = exports.evictableChildSpawn = exports.evictableMemoThenWaitForEvent = exports.MEMO_EVENT_KEY = exports.evictableWaitForEvent = exports.evictableSleepForGracefulTermination = exports.evictableSleep = exports.childTask = exports.EVENT_KEY = exports.LONG_SLEEP_SECONDS = exports.EVICTION_TTL_SECONDS = void 0;
|
|
16
16
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
17
|
const hatchet_client_1 = require("../hatchet-client");
|
|
18
18
|
exports.EVICTION_TTL_SECONDS = 5;
|
|
@@ -66,6 +66,20 @@ exports.evictableWaitForEvent = hatchet_client_1.hatchet.durableTask({
|
|
|
66
66
|
return { status: 'completed' };
|
|
67
67
|
}),
|
|
68
68
|
});
|
|
69
|
+
exports.MEMO_EVENT_KEY = 'durable-eviction:memo-event';
|
|
70
|
+
exports.evictableMemoThenWaitForEvent = hatchet_client_1.hatchet.durableTask({
|
|
71
|
+
name: 'evictable-memo-then-wait-for-event',
|
|
72
|
+
executionTimeout: '5m',
|
|
73
|
+
evictionPolicy: EVICTION_POLICY,
|
|
74
|
+
fn: (_input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
// now() records a memo node. On replay after eviction, the server
|
|
76
|
+
// re-delivers that node's completion, which never has a callback waiter
|
|
77
|
+
// and must not block the event completion queued behind it.
|
|
78
|
+
const memoizedNow = yield ctx.now();
|
|
79
|
+
yield ctx.waitForEvent(exports.MEMO_EVENT_KEY, 'true');
|
|
80
|
+
return { status: 'completed', memoizedNow: memoizedNow.toISOString() };
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
69
83
|
exports.evictableChildSpawn = hatchet_client_1.hatchet.durableTask({
|
|
70
84
|
name: 'evictable-child-spawn',
|
|
71
85
|
executionTimeout: '5m',
|
|
@@ -22,30 +22,33 @@ const cancellation_workflow_1 = require("./cancellation/cancellation-workflow");
|
|
|
22
22
|
const complex_workflow_1 = require("./conditions/complex-workflow");
|
|
23
23
|
const workflow_3 = require("./concurrency_cancel_in_progress/workflow");
|
|
24
24
|
const workflow_4 = require("./concurrency_cancel_newest/workflow");
|
|
25
|
-
const workflow_5 = require("./
|
|
26
|
-
const workflow_6 = require("./
|
|
27
|
-
const workflow_7 = require("./
|
|
28
|
-
const workflow_8 = require("./
|
|
29
|
-
const workflow_9 = require("./
|
|
30
|
-
const workflow_10 = require("./
|
|
31
|
-
const workflow_11 = require("./
|
|
32
|
-
const workflow_12 = require("./
|
|
33
|
-
const workflow_13 = require("./
|
|
34
|
-
const workflow_14 = require("./
|
|
35
|
-
const workflow_15 = require("./
|
|
36
|
-
const workflow_16 = require("./
|
|
37
|
-
const workflow_17 = require("./
|
|
38
|
-
const workflow_18 = require("./
|
|
25
|
+
const workflow_5 = require("./concurrency_cancel_queued_except_newest/workflow");
|
|
26
|
+
const workflow_6 = require("./concurrency_cancel_queued_except_oldest/workflow");
|
|
27
|
+
const workflow_7 = require("./concurrency_multiple_keys/workflow");
|
|
28
|
+
const workflow_8 = require("./concurrency_workflow_level/workflow");
|
|
29
|
+
const workflow_9 = require("./dag/workflow");
|
|
30
|
+
const workflow_10 = require("./durable/workflow");
|
|
31
|
+
const workflow_11 = require("./durable_event/workflow");
|
|
32
|
+
const workflow_12 = require("./durable_eviction/workflow");
|
|
33
|
+
const workflow_13 = require("./durable_callback_ordering/workflow");
|
|
34
|
+
const workflow_14 = require("./durable_sleep/workflow");
|
|
35
|
+
const workflow_15 = require("./logger/workflow");
|
|
36
|
+
const workflow_16 = require("./non_retryable/workflow");
|
|
37
|
+
const workflow_17 = require("./on_failure/workflow");
|
|
38
|
+
const workflow_18 = require("./idempotency/workflow");
|
|
39
|
+
const workflow_19 = require("./on_event/workflow");
|
|
40
|
+
const workflow_20 = require("./return_exceptions/workflow");
|
|
41
|
+
const workflow_21 = require("./run_details/workflow");
|
|
39
42
|
const e2e_workflows_1 = require("./simple/e2e-workflows");
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
43
|
+
const workflow_22 = require("./batch_assign/workflow");
|
|
44
|
+
const workflow_23 = require("./streaming/workflow");
|
|
45
|
+
const workflow_24 = require("./subscribe_to_stream/workflow");
|
|
46
|
+
const workflow_25 = require("./timeout/workflow");
|
|
47
|
+
const workflow_26 = require("./webhooks/workflow");
|
|
48
|
+
const workflow_27 = require("./child_index/workflow");
|
|
49
|
+
const workflow_28 = require("./support_agent/workflow");
|
|
50
|
+
const workflow_29 = require("./welcome_email/workflow");
|
|
51
|
+
const workflow_30 = require("./pdf_pipeline/workflow");
|
|
49
52
|
const workflows = [
|
|
50
53
|
workflow_1.bulkChild,
|
|
51
54
|
workflow_1.bulkParentWorkflow,
|
|
@@ -56,75 +59,81 @@ const workflows = [
|
|
|
56
59
|
complex_workflow_1.taskConditionWorkflow,
|
|
57
60
|
workflow_3.concurrencyCancelInProgressWorkflow,
|
|
58
61
|
workflow_4.concurrencyCancelNewestWorkflow,
|
|
59
|
-
workflow_5.
|
|
60
|
-
workflow_6.
|
|
61
|
-
workflow_7.
|
|
62
|
-
workflow_8.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
workflow_11.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
62
|
+
workflow_5.concurrencyCancelQueuedExceptNewestWorkflow,
|
|
63
|
+
workflow_6.concurrencyCancelQueuedExceptOldestWorkflow,
|
|
64
|
+
workflow_7.concurrencyMultipleKeysWorkflow,
|
|
65
|
+
workflow_8.concurrencyWorkflowLevelWorkflow,
|
|
66
|
+
workflow_9.dag,
|
|
67
|
+
workflow_10.durableWorkflow,
|
|
68
|
+
workflow_10.waitForSleepTwice,
|
|
69
|
+
workflow_10.spawnChildTask,
|
|
70
|
+
workflow_10.durableWithSpawn,
|
|
71
|
+
workflow_10.durableWithBulkSpawn,
|
|
72
|
+
workflow_10.durableSleepEventSpawn,
|
|
73
|
+
workflow_10.durableWithExplicitSpawn,
|
|
74
|
+
workflow_10.durableNonDeterminism,
|
|
75
|
+
workflow_10.durableReplayReset,
|
|
76
|
+
workflow_10.dagChildWorkflow,
|
|
77
|
+
workflow_10.durableSpawnDag,
|
|
78
|
+
workflow_10.waitForEventLookback,
|
|
79
|
+
workflow_10.waitForOrEventLookback,
|
|
80
|
+
workflow_10.waitForTwoEventsSecondPushedFirst,
|
|
81
|
+
workflow_10.errorRaisingTask,
|
|
82
|
+
workflow_10.errorRaisingDurableParent,
|
|
83
|
+
workflow_11.durableEvent,
|
|
84
|
+
workflow_11.durableEventWithFilter,
|
|
85
|
+
workflow_13.callbackOrderingLeaf,
|
|
86
|
+
workflow_13.callbackOrderingMid,
|
|
87
|
+
workflow_13.callbackOrderingRoot,
|
|
88
|
+
workflow_14.durableSleep,
|
|
89
|
+
workflow_12.evictableSleep,
|
|
90
|
+
workflow_12.evictableWaitForEvent,
|
|
91
|
+
workflow_12.evictableMemoThenWaitForEvent,
|
|
92
|
+
workflow_12.evictableChildSpawn,
|
|
93
|
+
workflow_12.multipleEviction,
|
|
94
|
+
workflow_12.nonEvictableSleep,
|
|
95
|
+
workflow_12.childTask,
|
|
96
|
+
workflow_12.bulkChildTask,
|
|
97
|
+
workflow_12.evictableChildBulkSpawn,
|
|
98
|
+
(0, workflow_15.createLoggingWorkflow)(hatchet_client_1.hatchet),
|
|
99
|
+
workflow_16.nonRetryableWorkflow,
|
|
100
|
+
workflow_17.failureWorkflow,
|
|
101
|
+
workflow_18.idempotentTask,
|
|
102
|
+
workflow_18.idempotentTaskShortWindow,
|
|
103
|
+
workflow_19.lower,
|
|
104
|
+
workflow_20.returnExceptionsTask,
|
|
105
|
+
workflow_21.runDetailTestWorkflow,
|
|
97
106
|
e2e_workflows_1.helloWorld,
|
|
98
107
|
e2e_workflows_1.helloWorldDurable,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
workflow_23.streamingTask,
|
|
109
|
+
workflow_24.dagStream,
|
|
110
|
+
workflow_24.longStream,
|
|
111
|
+
workflow_25.timeoutTask,
|
|
112
|
+
workflow_25.refreshTimeoutTask,
|
|
113
|
+
workflow_26.webhookWorkflow,
|
|
114
|
+
workflow_27.childIndexChild,
|
|
115
|
+
workflow_27.childIndexParent,
|
|
116
|
+
workflow_27.scenarioTask,
|
|
117
|
+
workflow_27.orchestratorTask,
|
|
118
|
+
workflow_28.supportAgent,
|
|
119
|
+
workflow_28.triageTicket,
|
|
120
|
+
workflow_28.generateReply,
|
|
121
|
+
workflow_28.escalateTicket,
|
|
122
|
+
workflow_29.welcomeEmail,
|
|
123
|
+
workflow_30.pdfPipeline,
|
|
124
|
+
workflow_22.batchSimple,
|
|
125
|
+
workflow_22.batchKeyed,
|
|
126
|
+
workflow_22.batchKeyedFailable,
|
|
127
|
+
workflow_22.batchKeyedInterval,
|
|
128
|
+
workflow_22.batchLarge,
|
|
129
|
+
workflow_22.batchSingle,
|
|
130
|
+
workflow_22.batchOrdered,
|
|
131
|
+
workflow_22.batchBroadcast,
|
|
132
|
+
workflow_22.batchCancel,
|
|
133
|
+
workflow_22.child,
|
|
134
|
+
workflow_22.childBatch,
|
|
135
|
+
workflow_22.batchChildSpawn,
|
|
136
|
+
workflow_22.batchChildBatchSpawn,
|
|
128
137
|
];
|
|
129
138
|
function main() {
|
|
130
139
|
return __awaiter(this, void 0, void 0, function* () {
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.30.1";
|
package/version.js
CHANGED