@hatchet-dev/typescript-sdk 1.16.0 → 1.17.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.
Files changed (94) hide show
  1. package/README.md +14 -2
  2. package/clients/admin/admin-client.d.ts +2 -2
  3. package/clients/dispatcher/action-listener.d.ts +3 -6
  4. package/clients/dispatcher/action-listener.js +12 -17
  5. package/clients/listeners/durable-listener/durable-listener-client.d.ts +115 -15
  6. package/clients/listeners/durable-listener/durable-listener-client.js +769 -19
  7. package/clients/listeners/durable-listener/pooled-durable-listener-client.js +1 -14
  8. package/clients/listeners/run-listener/pooled-child-listener-client.js +1 -14
  9. package/clients/rest/generated/Api.d.ts +5 -1
  10. package/clients/rest/generated/data-contracts.d.ts +16 -2
  11. package/clients/rest/generated/data-contracts.js +7 -3
  12. package/legacy/examples/affinity-workers.js +2 -2
  13. package/legacy/legacy-client.js +1 -1
  14. package/legacy/step.d.ts +2 -2
  15. package/legacy/step.js +3 -2
  16. package/legacy/workflow.d.ts +25 -25
  17. package/package.json +1 -1
  18. package/protoc/dispatcher/dispatcher.d.ts +20 -0
  19. package/protoc/dispatcher/dispatcher.js +136 -2
  20. package/protoc/v1/dispatcher.d.ts +168 -0
  21. package/protoc/v1/dispatcher.js +1920 -1
  22. package/protoc/v1/shared/trigger.d.ts +89 -0
  23. package/protoc/v1/shared/trigger.js +493 -0
  24. package/protoc/v1/workflows.d.ts +34 -34
  25. package/protoc/v1/workflows.js +252 -200
  26. package/protoc/workflows/workflows.d.ts +2 -75
  27. package/protoc/workflows/workflows.js +16 -491
  28. package/util/abort-error.d.ts +10 -0
  29. package/util/abort-error.js +15 -0
  30. package/util/errors/eviction-not-supported-error.d.ts +5 -0
  31. package/util/errors/eviction-not-supported-error.js +18 -0
  32. package/util/errors/non-determinism-error.d.ts +7 -0
  33. package/util/errors/non-determinism-error.js +21 -0
  34. package/util/errors/task-run-terminated-error.d.ts +6 -0
  35. package/util/errors/task-run-terminated-error.js +15 -0
  36. package/util/hatchet-promise/hatchet-promise.d.ts +2 -1
  37. package/util/hatchet-promise/hatchet-promise.js +10 -1
  38. package/util/sleep.d.ts +3 -2
  39. package/util/sleep.js +6 -4
  40. package/v1/client/admin.d.ts +2 -2
  41. package/v1/client/client.js +1 -1
  42. package/v1/client/duration.d.ts +11 -1
  43. package/v1/client/duration.js +44 -0
  44. package/v1/client/features/runs.d.ts +16 -3
  45. package/v1/client/features/runs.js +38 -3
  46. package/v1/client/worker/context.d.ts +101 -6
  47. package/v1/client/worker/context.js +247 -21
  48. package/v1/client/worker/deprecated/index.d.ts +1 -1
  49. package/v1/client/worker/deprecated/index.js +2 -1
  50. package/v1/client/worker/deprecated/legacy-worker.d.ts +5 -0
  51. package/v1/client/worker/deprecated/legacy-worker.js +32 -23
  52. package/v1/client/worker/deprecated/pre-eviction.d.ts +12 -0
  53. package/v1/client/worker/deprecated/pre-eviction.js +37 -0
  54. package/v1/client/worker/engine-version.d.ts +5 -0
  55. package/v1/client/worker/engine-version.js +14 -0
  56. package/v1/client/worker/eviction/eviction-cache.d.ts +33 -0
  57. package/v1/client/worker/eviction/eviction-cache.js +139 -0
  58. package/v1/client/worker/eviction/eviction-manager.d.ts +42 -0
  59. package/v1/client/worker/eviction/eviction-manager.js +132 -0
  60. package/v1/client/worker/eviction/eviction-policy.d.ts +19 -0
  61. package/v1/client/worker/eviction/eviction-policy.js +8 -0
  62. package/v1/client/worker/eviction/index.d.ts +3 -0
  63. package/v1/client/worker/eviction/index.js +11 -0
  64. package/v1/client/worker/worker-internal.d.ts +23 -4
  65. package/v1/client/worker/worker-internal.js +177 -138
  66. package/v1/client/worker/worker.d.ts +1 -0
  67. package/v1/client/worker/worker.js +34 -1
  68. package/v1/conditions/sleep-condition.js +2 -1
  69. package/v1/conditions/transformer.js +2 -1
  70. package/v1/declaration.d.ts +5 -3
  71. package/v1/declaration.js +8 -0
  72. package/v1/examples/__e2e__/harness.d.ts +5 -0
  73. package/v1/examples/__e2e__/harness.js +13 -0
  74. package/v1/examples/concurrency_workflow_level/workflow.d.ts +1 -1
  75. package/v1/examples/concurrency_workflow_level/workflow.js +1 -1
  76. package/v1/examples/durable/workflow.d.ts +57 -0
  77. package/v1/examples/durable/workflow.js +162 -7
  78. package/v1/examples/durable-event/workflow.js +2 -7
  79. package/v1/examples/durable_event/workflow.d.ts +1 -0
  80. package/v1/examples/durable_event/workflow.js +4 -9
  81. package/v1/examples/durable_eviction/capacity-worker.d.ts +1 -0
  82. package/v1/examples/durable_eviction/capacity-worker.js +31 -0
  83. package/v1/examples/durable_eviction/worker.d.ts +1 -0
  84. package/v1/examples/durable_eviction/worker.js +34 -0
  85. package/v1/examples/durable_eviction/workflow.d.ts +44 -0
  86. package/v1/examples/durable_eviction/workflow.js +129 -0
  87. package/v1/examples/e2e-worker.js +42 -19
  88. package/v1/index.d.ts +5 -0
  89. package/v1/index.js +10 -0
  90. package/v1/parent-run-context-vars.d.ts +6 -0
  91. package/v1/task.d.ts +10 -2
  92. package/v1/task.js +2 -1
  93. package/version.d.ts +1 -1
  94. package/version.js +1 -1
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DurableEvictionCache = exports.EvictionCause = void 0;
4
+ exports.buildEvictionReason = buildEvictionReason;
5
+ const duration_1 = require("../../duration");
6
+ var EvictionCause;
7
+ (function (EvictionCause) {
8
+ EvictionCause["TTL_EXCEEDED"] = "ttl_exceeded";
9
+ EvictionCause["CAPACITY_PRESSURE"] = "capacity_pressure";
10
+ EvictionCause["WORKER_SHUTDOWN"] = "worker_shutdown";
11
+ })(EvictionCause || (exports.EvictionCause = EvictionCause = {}));
12
+ class DurableEvictionCache {
13
+ constructor() {
14
+ this._runs = new Map();
15
+ }
16
+ registerRun(key, taskRunExternalId, invocationCount, now, evictionPolicy) {
17
+ this._runs.set(key, {
18
+ key,
19
+ taskRunExternalId,
20
+ invocationCount,
21
+ evictionPolicy,
22
+ registeredAt: now,
23
+ waitingSince: undefined,
24
+ waitKind: undefined,
25
+ waitResourceId: undefined,
26
+ _waitCount: 0,
27
+ evictionReason: undefined,
28
+ });
29
+ }
30
+ unregisterRun(key) {
31
+ this._runs.delete(key);
32
+ }
33
+ get(key) {
34
+ return this._runs.get(key);
35
+ }
36
+ getAllWaiting() {
37
+ return [...this._runs.values()].filter((r) => r._waitCount > 0);
38
+ }
39
+ findKeyByTaskRunExternalId(taskRunExternalId) {
40
+ for (const [key, rec] of this._runs) {
41
+ if (rec.taskRunExternalId === taskRunExternalId)
42
+ return key;
43
+ }
44
+ return undefined;
45
+ }
46
+ markWaiting(key, now, waitKind, resourceId) {
47
+ const rec = this._runs.get(key);
48
+ if (!rec)
49
+ return;
50
+ rec._waitCount += 1;
51
+ if (rec._waitCount === 1) {
52
+ rec.waitingSince = now;
53
+ }
54
+ rec.waitKind = waitKind;
55
+ rec.waitResourceId = resourceId;
56
+ }
57
+ markActive(key) {
58
+ const rec = this._runs.get(key);
59
+ if (!rec)
60
+ return;
61
+ rec._waitCount = Math.max(0, rec._waitCount - 1);
62
+ if (rec._waitCount === 0) {
63
+ rec.waitingSince = undefined;
64
+ rec.waitKind = undefined;
65
+ rec.waitResourceId = undefined;
66
+ }
67
+ }
68
+ selectEvictionCandidate(now, durableSlots, reserveSlots, minWaitForCapacityEvictionMs) {
69
+ const waiting = [...this._runs.values()].filter((r) => r._waitCount > 0 && r.evictionPolicy !== undefined);
70
+ if (waiting.length === 0)
71
+ return undefined;
72
+ const ttlEligible = waiting.filter((r) => {
73
+ var _a;
74
+ const ttl = (_a = r.evictionPolicy) === null || _a === void 0 ? void 0 : _a.ttl;
75
+ if (!ttl || !r.waitingSince)
76
+ return false;
77
+ return now - r.waitingSince >= (0, duration_1.durationToMs)(ttl);
78
+ });
79
+ if (ttlEligible.length > 0) {
80
+ ttlEligible.sort((a, b) => {
81
+ var _a, _b, _c, _d, _e, _f;
82
+ return ((_b = (_a = a.evictionPolicy) === null || _a === void 0 ? void 0 : _a.priority) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = b.evictionPolicy) === null || _c === void 0 ? void 0 : _c.priority) !== null && _d !== void 0 ? _d : 0) ||
83
+ ((_e = a.waitingSince) !== null && _e !== void 0 ? _e : now) - ((_f = b.waitingSince) !== null && _f !== void 0 ? _f : now);
84
+ });
85
+ const [chosen] = ttlEligible;
86
+ chosen.evictionReason = buildEvictionReason(EvictionCause.TTL_EXCEEDED, chosen);
87
+ return chosen.key;
88
+ }
89
+ if (!this._hasCapacityPressure(durableSlots, reserveSlots, waiting.length)) {
90
+ return undefined;
91
+ }
92
+ const capacityCandidates = waiting.filter((r) => {
93
+ var _a;
94
+ return ((_a = r.evictionPolicy) === null || _a === void 0 ? void 0 : _a.allowCapacityEviction) !== false &&
95
+ r.waitingSince !== undefined &&
96
+ now - r.waitingSince >= minWaitForCapacityEvictionMs;
97
+ });
98
+ if (capacityCandidates.length === 0)
99
+ return undefined;
100
+ capacityCandidates.sort((a, b) => {
101
+ var _a, _b, _c, _d, _e, _f;
102
+ return ((_b = (_a = a.evictionPolicy) === null || _a === void 0 ? void 0 : _a.priority) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = b.evictionPolicy) === null || _c === void 0 ? void 0 : _c.priority) !== null && _d !== void 0 ? _d : 0) ||
103
+ ((_e = a.waitingSince) !== null && _e !== void 0 ? _e : now) - ((_f = b.waitingSince) !== null && _f !== void 0 ? _f : now);
104
+ });
105
+ const [chosen] = capacityCandidates;
106
+ chosen.evictionReason = buildEvictionReason(EvictionCause.CAPACITY_PRESSURE, chosen);
107
+ return chosen.key;
108
+ }
109
+ _hasCapacityPressure(durableSlots, reserveSlots, waitingCount) {
110
+ if (durableSlots <= 0)
111
+ return false;
112
+ const maxWaiting = durableSlots - reserveSlots;
113
+ if (maxWaiting <= 0)
114
+ return false;
115
+ return waitingCount >= maxWaiting;
116
+ }
117
+ }
118
+ exports.DurableEvictionCache = DurableEvictionCache;
119
+ function buildEvictionReason(cause, rec) {
120
+ var _a;
121
+ let waitDesc = rec.waitKind || 'unknown';
122
+ if (rec.waitResourceId) {
123
+ waitDesc = `${waitDesc}(${rec.waitResourceId})`;
124
+ }
125
+ switch (cause) {
126
+ case EvictionCause.TTL_EXCEEDED: {
127
+ const ttlStr = ((_a = rec.evictionPolicy) === null || _a === void 0 ? void 0 : _a.ttl) ? ` (${rec.evictionPolicy.ttl})` : '';
128
+ return `Wait TTL${ttlStr} exceeded while waiting on ${waitDesc}`;
129
+ }
130
+ case EvictionCause.CAPACITY_PRESSURE:
131
+ return `Worker at capacity while waiting on ${waitDesc}`;
132
+ case EvictionCause.WORKER_SHUTDOWN:
133
+ return `Worker shutdown while waiting on ${waitDesc}`;
134
+ default: {
135
+ const _exhaustive = cause;
136
+ throw new Error(`Unknown eviction cause: ${_exhaustive}`);
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,42 @@
1
+ import { Logger } from '../../../../util/logger';
2
+ import { EvictionPolicy } from './eviction-policy';
3
+ import { ActionKey, DurableEvictionCache, DurableRunRecord } from './eviction-cache';
4
+ export interface DurableEvictionConfig {
5
+ /** How often we try selecting an eviction candidate. Default: 1000ms */
6
+ checkIntervalMs?: number;
7
+ /** How many slots to reserve from capacity-based eviction decisions. Default: 0 */
8
+ reserveSlots?: number;
9
+ /** Avoid immediately evicting runs that just entered a wait. Default: 10000ms */
10
+ minWaitForCapacityEvictionMs?: number;
11
+ }
12
+ export declare const DEFAULT_DURABLE_EVICTION_CONFIG: Required<DurableEvictionConfig>;
13
+ export declare class DurableEvictionManager {
14
+ private _durableSlots;
15
+ private _cancelLocal;
16
+ private _requestEvictionWithAck;
17
+ private _config;
18
+ private _cache;
19
+ private _logger;
20
+ private _timer;
21
+ private _ticking;
22
+ constructor(opts: {
23
+ durableSlots: number;
24
+ cancelLocal: (key: ActionKey) => void;
25
+ requestEvictionWithAck: (key: ActionKey, rec: DurableRunRecord) => Promise<void>;
26
+ config?: DurableEvictionConfig;
27
+ cache?: DurableEvictionCache;
28
+ logger: Logger;
29
+ });
30
+ get cache(): DurableEvictionCache;
31
+ start(): void;
32
+ stop(): void;
33
+ registerRun(key: ActionKey, taskRunExternalId: string, invocationCount: number, evictionPolicy: EvictionPolicy | undefined): void;
34
+ unregisterRun(key: ActionKey): void;
35
+ markWaiting(key: ActionKey, waitKind: string, resourceId: string): void;
36
+ markActive(key: ActionKey): void;
37
+ private _evictRun;
38
+ private _tickSafe;
39
+ private _tick;
40
+ handleServerEviction(taskRunExternalId: string, invocationCount: number): void;
41
+ evictAllWaiting(): Promise<number>;
42
+ }
@@ -0,0 +1,132 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DurableEvictionManager = exports.DEFAULT_DURABLE_EVICTION_CONFIG = void 0;
13
+ const eviction_cache_1 = require("./eviction-cache");
14
+ const hatchet_error_1 = require("../../../../util/errors/hatchet-error");
15
+ exports.DEFAULT_DURABLE_EVICTION_CONFIG = {
16
+ checkIntervalMs: 1000,
17
+ reserveSlots: 0,
18
+ minWaitForCapacityEvictionMs: 10000,
19
+ };
20
+ class DurableEvictionManager {
21
+ constructor(opts) {
22
+ this._ticking = false;
23
+ this._durableSlots = opts.durableSlots;
24
+ this._cancelLocal = opts.cancelLocal;
25
+ this._requestEvictionWithAck = opts.requestEvictionWithAck;
26
+ this._config = Object.assign(Object.assign({}, exports.DEFAULT_DURABLE_EVICTION_CONFIG), opts.config);
27
+ this._cache = opts.cache || new eviction_cache_1.DurableEvictionCache();
28
+ this._logger = opts.logger;
29
+ }
30
+ get cache() {
31
+ return this._cache;
32
+ }
33
+ start() {
34
+ if (this._timer)
35
+ return;
36
+ this._timer = setInterval(() => this._tickSafe(), this._config.checkIntervalMs);
37
+ }
38
+ stop() {
39
+ if (this._timer) {
40
+ clearInterval(this._timer);
41
+ this._timer = undefined;
42
+ }
43
+ }
44
+ registerRun(key, taskRunExternalId, invocationCount, evictionPolicy) {
45
+ this._cache.registerRun(key, taskRunExternalId, invocationCount, Date.now(), evictionPolicy);
46
+ }
47
+ unregisterRun(key) {
48
+ this._cache.unregisterRun(key);
49
+ }
50
+ markWaiting(key, waitKind, resourceId) {
51
+ this._cache.markWaiting(key, Date.now(), waitKind, resourceId);
52
+ }
53
+ markActive(key) {
54
+ this._cache.markActive(key);
55
+ }
56
+ _evictRun(key) {
57
+ this._cancelLocal(key);
58
+ this.unregisterRun(key);
59
+ }
60
+ _tickSafe() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ if (this._ticking)
63
+ return;
64
+ this._ticking = true;
65
+ try {
66
+ yield this._tick();
67
+ }
68
+ catch (err) {
69
+ this._logger.error(`DurableEvictionManager: error in eviction loop: ${(0, hatchet_error_1.getErrorMessage)(err)}`);
70
+ }
71
+ finally {
72
+ this._ticking = false;
73
+ }
74
+ });
75
+ }
76
+ _tick() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const evictedThisTick = new Set();
79
+ while (true) {
80
+ const key = this._cache.selectEvictionCandidate(Date.now(), this._durableSlots, this._config.reserveSlots, this._config.minWaitForCapacityEvictionMs);
81
+ if (!key)
82
+ return;
83
+ if (evictedThisTick.has(key))
84
+ return;
85
+ evictedThisTick.add(key);
86
+ const rec = this._cache.get(key);
87
+ if (!rec || !rec.evictionPolicy)
88
+ continue;
89
+ this._logger.debug(`DurableEvictionManager: evicting task_run_external_id=${rec.taskRunExternalId} ` +
90
+ `wait_kind=${rec.waitKind} resource_id=${rec.waitResourceId}`);
91
+ yield this._requestEvictionWithAck(key, rec);
92
+ this._evictRun(key);
93
+ }
94
+ });
95
+ }
96
+ handleServerEviction(taskRunExternalId, invocationCount) {
97
+ const key = this._cache.findKeyByTaskRunExternalId(taskRunExternalId);
98
+ if (!key)
99
+ return;
100
+ const rec = this._cache.get(key);
101
+ if (rec && rec.invocationCount !== invocationCount)
102
+ return;
103
+ this._logger.info(`DurableEvictionManager: server-initiated eviction for task_run_external_id=${taskRunExternalId} invocation_count=${invocationCount}`);
104
+ this._evictRun(key);
105
+ }
106
+ evictAllWaiting() {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ this.stop();
109
+ const waiting = this._cache.getAllWaiting();
110
+ let evicted = 0;
111
+ for (const rec of waiting) {
112
+ rec.evictionReason = (0, eviction_cache_1.buildEvictionReason)(eviction_cache_1.EvictionCause.WORKER_SHUTDOWN, rec);
113
+ this._logger.debug(`DurableEvictionManager: shutdown-evicting task_run_external_id=${rec.taskRunExternalId} ` +
114
+ `wait_kind=${rec.waitKind}`);
115
+ try {
116
+ yield this._requestEvictionWithAck(rec.key, rec);
117
+ }
118
+ catch (err) {
119
+ this._logger.error(`DurableEvictionManager: failed to send eviction for ` +
120
+ `task_run_external_id=${rec.taskRunExternalId}: ${(0, hatchet_error_1.getErrorMessage)(err)}`);
121
+ }
122
+ // Always cancel locally even if the server ACK failed, so the
123
+ // future settles and exitGracefully doesn't hang.
124
+ // This will get resolved by the reassignment of the task.
125
+ this._evictRun(rec.key);
126
+ evicted++;
127
+ }
128
+ return evicted;
129
+ });
130
+ }
131
+ }
132
+ exports.DurableEvictionManager = DurableEvictionManager;
@@ -0,0 +1,19 @@
1
+ import { Duration } from '../../duration';
2
+ export type EvictionPolicy = {
3
+ /**
4
+ * Maximum continuous waiting duration before TTL-eligible eviction.
5
+ * `undefined` means no TTL-based eviction.
6
+ */
7
+ ttl?: Duration;
8
+ /**
9
+ * Whether this task may be evicted under durable-slot pressure.
10
+ * @default true
11
+ */
12
+ allowCapacityEviction?: boolean;
13
+ /**
14
+ * Lower values are evicted first when multiple candidates exist.
15
+ * @default 0
16
+ */
17
+ priority?: number;
18
+ };
19
+ export declare const DEFAULT_DURABLE_TASK_EVICTION_POLICY: EvictionPolicy;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = void 0;
4
+ exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = {
5
+ ttl: '15m',
6
+ allowCapacityEviction: true,
7
+ priority: 0,
8
+ };
@@ -0,0 +1,3 @@
1
+ export { EvictionPolicy, DEFAULT_DURABLE_TASK_EVICTION_POLICY } from './eviction-policy';
2
+ export { DurableEvictionCache, ActionKey, DurableRunRecord, EvictionCause } from './eviction-cache';
3
+ export { DurableEvictionManager, DurableEvictionConfig, DEFAULT_DURABLE_EVICTION_CONFIG, } from './eviction-manager';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_DURABLE_EVICTION_CONFIG = exports.DurableEvictionManager = exports.EvictionCause = exports.DurableEvictionCache = exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = void 0;
4
+ var eviction_policy_1 = require("./eviction-policy");
5
+ Object.defineProperty(exports, "DEFAULT_DURABLE_TASK_EVICTION_POLICY", { enumerable: true, get: function () { return eviction_policy_1.DEFAULT_DURABLE_TASK_EVICTION_POLICY; } });
6
+ var eviction_cache_1 = require("./eviction-cache");
7
+ Object.defineProperty(exports, "DurableEvictionCache", { enumerable: true, get: function () { return eviction_cache_1.DurableEvictionCache; } });
8
+ Object.defineProperty(exports, "EvictionCause", { enumerable: true, get: function () { return eviction_cache_1.EvictionCause; } });
9
+ var eviction_manager_1 = require("./eviction-manager");
10
+ Object.defineProperty(exports, "DurableEvictionManager", { enumerable: true, get: function () { return eviction_manager_1.DurableEvictionManager; } });
11
+ Object.defineProperty(exports, "DEFAULT_DURABLE_EVICTION_CONFIG", { enumerable: true, get: function () { return eviction_manager_1.DEFAULT_DURABLE_EVICTION_CONFIG; } });
@@ -1,4 +1,4 @@
1
- import { Action, ActionListener } from '../../../clients/dispatcher/action-listener';
1
+ import { Action, ActionKey, ActionListener } from '../../../clients/dispatcher/action-listener';
2
2
  import { StepActionEvent, StepActionEventType, GroupKeyActionEvent, GroupKeyActionEventType } from '../../../protoc/dispatcher';
3
3
  import HatchetPromise from '../../../util/hatchet-promise/hatchet-promise';
4
4
  import { CreateStepRateLimit } from '../../../protoc/workflows';
@@ -6,8 +6,11 @@ import { Logger } from '../../../util/logger';
6
6
  import { BaseWorkflowDeclaration, WorkflowDefinition, HatchetClient } from '../..';
7
7
  import { CreateWorkflowTaskOpts } from '../../task';
8
8
  import { WorkerLabels } from '../../../clients/dispatcher/dispatcher-client';
9
+ import { Duration } from '../duration';
9
10
  import { Context } from './context';
10
11
  import { SlotConfig } from '../../slot-types';
12
+ import { DurableEvictionManager } from './eviction/eviction-manager';
13
+ import { EvictionPolicy } from './eviction/eviction-policy';
11
14
  export type ActionRegistry = Record<Action['actionId'], Function>;
12
15
  export interface WorkerOpts {
13
16
  name: string;
@@ -25,13 +28,17 @@ export declare class InternalWorker {
25
28
  killing: boolean;
26
29
  handle_kill: boolean;
27
30
  action_registry: ActionRegistry;
31
+ durable_action_set: Set<string>;
32
+ eviction_policies: Map<string, EvictionPolicy | undefined>;
33
+ evictionManager: DurableEvictionManager | undefined;
28
34
  workflow_registry: Array<WorkflowDefinition>;
29
35
  listener: ActionListener | undefined;
30
- futures: Record<Action['taskRunExternalId'], HatchetPromise<any>>;
31
- contexts: Record<Action['taskRunExternalId'], Context<any, any>>;
36
+ futures: Record<ActionKey, HatchetPromise<any>>;
37
+ contexts: Record<ActionKey, Context<any, any>>;
32
38
  slots?: number;
33
39
  durableSlots?: number;
34
40
  slotConfig: SlotConfig;
41
+ engineVersion: string | undefined;
35
42
  logger: Logger;
36
43
  registeredWorkflowPromises: Array<Promise<any>>;
37
44
  labels: WorkerLabels;
@@ -55,8 +62,9 @@ export declare class InternalWorker {
55
62
  registerDurableActions(workflow: WorkflowDefinition): void;
56
63
  private registerActions;
57
64
  registerWorkflow(initWorkflow: BaseWorkflowDeclaration<any, any>, durable?: boolean): Promise<void>;
65
+ private ensureEvictionManager;
66
+ private cleanupRun;
58
67
  handleStartStepRun(action: Action): Promise<void>;
59
- handleStartGroupKeyRun(action: Action): Promise<void>;
60
68
  getStepActionEvent(action: Action, eventType: StepActionEventType, shouldNotRetry: boolean, payload?: any, retryCount?: number): StepActionEvent;
61
69
  getGroupKeyActionEvent(action: Action, eventType: GroupKeyActionEventType, payload?: any): GroupKeyActionEvent;
62
70
  handleCancelStepRun(action: Action): Promise<void>;
@@ -72,3 +80,14 @@ export declare class InternalWorker {
72
80
  upsertLabels(labels: WorkerLabels): Promise<WorkerLabels>;
73
81
  }
74
82
  export declare function mapRateLimitPb(limits: CreateWorkflowTaskOpts<any, any>['rateLimits']): CreateStepRateLimit[];
83
+ export declare function resolveExecutionTimeout(task: {
84
+ executionTimeout?: Duration;
85
+ timeout?: Duration;
86
+ }, workflowDefaults?: {
87
+ executionTimeout?: Duration;
88
+ }): string;
89
+ export declare function resolveScheduleTimeout(task: {
90
+ scheduleTimeout?: Duration;
91
+ }, workflowDefaults?: {
92
+ scheduleTimeout?: Duration;
93
+ }): string | undefined;