@plitzi/sdk-actions 0.39.10 → 0.39.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/chunks/{load-qeEXWO8c.mjs → load-tw8iAgZy.mjs} +1 -1
- package/dist/chunks/{module-BP0LBhlj.mjs → module-Baod2T6h.mjs} +12 -17
- package/dist/chunks/{queueDocument-veQsE-_i.mjs → queueDocument-DCBWcxe_.mjs} +1 -1
- package/dist/chunks/{queueRules-C6jJo_yv.mjs → queueRules-UGZNkho0.mjs} +99 -27
- package/dist/chunks/{taskCatalog-Dp8XjA8_.mjs → taskCatalog-J9hBMCsz.mjs} +1 -1
- package/dist/engine/jobs/jobGroups.d.ts +7 -0
- package/dist/engine/jobs/waitingRules.d.ts +10 -0
- package/dist/engine/runtime/flags.d.ts +1 -1
- package/dist/engine/runtime/guards.d.ts +5 -9
- package/dist/engine/types.d.ts +5 -0
- package/dist/functions/index.mjs +2 -2
- package/dist/functions/jobControl.d.ts +3 -3
- package/dist/index.mjs +16 -8
- package/dist/mongo/index.mjs +109 -19
- package/dist/mongo/jobLists.d.ts +19 -0
- package/dist/mongo/resumeWaiting.d.ts +10 -0
- package/dist/mysql/index.mjs +138 -24
- package/dist/mysql/jobLists.d.ts +18 -0
- package/dist/mysql/resumeWaiting.d.ts +12 -0
- package/dist/mysql/rows.d.ts +5 -0
- package/dist/sqlite/index.mjs +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jobs.d.ts +42 -0
- package/dist/worker/index.mjs +5 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @plitzi/sdk-actions
|
|
2
2
|
|
|
3
|
+
## 0.39.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f5b44d: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [2f5b44d]
|
|
10
|
+
- @plitzi/sdk-kernel@0.39.12
|
|
11
|
+
- @plitzi/sdk-shared@0.39.12
|
|
12
|
+
|
|
13
|
+
## 0.39.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- d0b5be6: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
18
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
19
|
+
- Updated dependencies [d0b5be6]
|
|
20
|
+
- @plitzi/sdk-kernel@0.39.11
|
|
21
|
+
- @plitzi/sdk-shared@0.39.11
|
|
22
|
+
|
|
3
23
|
## 0.39.10
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as buildFunctions } from "./module-
|
|
1
|
+
import { i as buildFunctions } from "./module-Baod2T6h.mjs";
|
|
2
2
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
3
3
|
import { readFunctionsSource } from "@plitzi/sdk-shared/actions";
|
|
4
4
|
import { readFile, readdir } from "node:fs/promises";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as emptyState, o as queueOver, p as SET_ASIDE_WORDS, r as applyRule, s as queueRules } from "./queueRules-
|
|
1
|
+
import { a as emptyState, o as queueOver, p as SET_ASIDE_WORDS, r as applyRule, s as queueRules } from "./queueRules-UGZNkho0.mjs";
|
|
2
2
|
import { a as triggerParams, i as findTriggerNode, n as RunLimitReached, r as limitOf, t as ActionRunError } from "./errors-bCBfIe7c.mjs";
|
|
3
3
|
import { i as KV_METHODS, n as MAX_GRANT_SECONDS, o as createMemoryKv, t as DEFAULT_GRANT_SECONDS } from "./grants-BsD-WlLE.mjs";
|
|
4
4
|
import { cappedResponse, fetchOutbound, isBlockedHost } from "@plitzi/sdk-kernel/outbound";
|
|
@@ -422,6 +422,7 @@ var JOB_QUEUE_METHODS = {
|
|
|
422
422
|
advanceSchedule: true,
|
|
423
423
|
putSchedules: true,
|
|
424
424
|
listJobs: true,
|
|
425
|
+
listJobGroups: true,
|
|
425
426
|
listAcross: true,
|
|
426
427
|
summarize: true,
|
|
427
428
|
countDue: true,
|
|
@@ -433,7 +434,8 @@ var JOB_QUEUE_METHODS = {
|
|
|
433
434
|
pause: true,
|
|
434
435
|
resume: true,
|
|
435
436
|
cancelPending: true,
|
|
436
|
-
cancelWaiting: true
|
|
437
|
+
cancelWaiting: true,
|
|
438
|
+
resumeWaiting: true
|
|
437
439
|
};
|
|
438
440
|
/**
|
|
439
441
|
* The default queue: one process's Maps.
|
|
@@ -1748,21 +1750,13 @@ var createRunGuards = (config = {}, store, idempotency = {}) => {
|
|
|
1748
1750
|
return total;
|
|
1749
1751
|
};
|
|
1750
1752
|
/**
|
|
1751
|
-
* Takes the key, here and — when there is one — everywhere
|
|
1752
|
-
*
|
|
1753
|
-
* `
|
|
1754
|
-
*
|
|
1755
|
-
* that same caller, which is the rule `createKvStore` already follows for a rate-limit window; the gap between
|
|
1756
|
-
* the two calls is a key that outlives its holder if the process dies inside it, and it is the same gap that
|
|
1757
|
-
* idiom has always had.
|
|
1753
|
+
* Takes the key, here and — when there is one — everywhere: written only where nothing holds it, with its lifetime in
|
|
1754
|
+
* the same write (`swap`), and holding the run's id. Never a key without one: taken by `increment` and given its
|
|
1755
|
+
* lifetime by an `expire` after, a store that timed out on the second (a rollout's Redis did) kept the key for good —
|
|
1756
|
+
* every later run of it refused as "already running" while nothing ran, its job back in the queue every second.
|
|
1758
1757
|
*/
|
|
1759
1758
|
const ttlSeconds = (ttlMs) => Math.max(1, Math.ceil(ttlMs / 1e3));
|
|
1760
|
-
const takeShared = async (runKey, ttlMs) => {
|
|
1761
|
-
if (!store) return true;
|
|
1762
|
-
if (await store.increment(`${keyPrefix}${runKey}`, 1) !== 1) return false;
|
|
1763
|
-
await store.expire(`${keyPrefix}${runKey}`, ttlSeconds(ttlMs));
|
|
1764
|
-
return true;
|
|
1765
|
-
};
|
|
1759
|
+
const takeShared = async (runKey, runId, ttlMs) => store ? store.swap(`${keyPrefix}${runKey}`, void 0, runId, ttlSeconds(ttlMs)) : true;
|
|
1766
1760
|
const begin = async (params) => {
|
|
1767
1761
|
sweep();
|
|
1768
1762
|
const runKey = deriveRunKey(params);
|
|
@@ -1810,7 +1804,7 @@ var createRunGuards = (config = {}, store, idempotency = {}) => {
|
|
|
1810
1804
|
byKey.set(runKey, run);
|
|
1811
1805
|
byId.set(run.runId, run);
|
|
1812
1806
|
try {
|
|
1813
|
-
if (!await takeShared(runKey, params.ttlMs)) throw new ActionRunError("duplicate", "This action is already running");
|
|
1807
|
+
if (!await takeShared(runKey, run.runId, params.ttlMs)) throw new ActionRunError("duplicate", "This action is already running");
|
|
1814
1808
|
} catch (error) {
|
|
1815
1809
|
byKey.delete(runKey);
|
|
1816
1810
|
byId.delete(run.runId);
|
|
@@ -2319,7 +2313,8 @@ var flagsForRun = async (config, request) => {
|
|
|
2319
2313
|
undeclaredFlagOverrides(declared, { server: overrides.server }).forEach(({ name }) => serverLog.warn("Actions", `The server sets the flag "${name}", which space ${spaceId} does not declare.`));
|
|
2320
2314
|
return flagValues(resolveFlags(declared, {
|
|
2321
2315
|
environment,
|
|
2322
|
-
user: flagUserFromSSR(user)
|
|
2316
|
+
user: flagUserFromSSR(user),
|
|
2317
|
+
rollout: request.rolloutBuckets
|
|
2323
2318
|
}, overrides));
|
|
2324
2319
|
};
|
|
2325
2320
|
// src/engine/runtime/scope.ts
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
1
2
|
import { isTerminalJobStatus } from "@plitzi/sdk-shared/actions";
|
|
2
3
|
// src/engine/jobs/flow.ts
|
|
3
4
|
var MINUTE = 6e4;
|
|
@@ -53,6 +54,37 @@ var flowOf = (jobs, from, to) => {
|
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
56
|
};
|
|
57
|
+
// src/engine/jobs/jobGroups.ts
|
|
58
|
+
/**
|
|
59
|
+
* Jobs, the most recently touched first, as `JobQueue.listJobGroups` answers them: a group per space, work and status,
|
|
60
|
+
* in the order their latest jobs come — what the in-process stores' rules (`queueRules`) page.
|
|
61
|
+
*/
|
|
62
|
+
var groupJobs = (newestFirst) => {
|
|
63
|
+
const groups = /* @__PURE__ */ new Map();
|
|
64
|
+
for (const job of newestFirst) {
|
|
65
|
+
const key = [
|
|
66
|
+
job.spaceId,
|
|
67
|
+
job.target.kind,
|
|
68
|
+
job.target.name,
|
|
69
|
+
job.status
|
|
70
|
+
].join("\0");
|
|
71
|
+
const group = groups.get(key);
|
|
72
|
+
if (group) {
|
|
73
|
+
group.count += 1;
|
|
74
|
+
group.firstDueAt = Math.min(group.firstDueAt, job.dueAt);
|
|
75
|
+
group.lastDueAt = Math.max(group.lastDueAt, job.dueAt);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const { state: _state, ...latest } = job;
|
|
79
|
+
groups.set(key, {
|
|
80
|
+
latest,
|
|
81
|
+
count: 1,
|
|
82
|
+
firstDueAt: job.dueAt,
|
|
83
|
+
lastDueAt: job.dueAt
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return [...groups.values()];
|
|
87
|
+
};
|
|
56
88
|
// src/engine/jobs/memoryNeeds.ts
|
|
57
89
|
/**
|
|
58
90
|
* What a job needs once the worker running it died, in the words every store writes: the in-process ones through
|
|
@@ -81,6 +113,46 @@ var needsAfterLoss = (needsMb, holderMb, outgrew) => holderMb === void 0 || !out
|
|
|
81
113
|
var lostError = (holderMb, outgrew) => holderMb === void 0 || !outgrew ? LOST_ERROR : `${LOST_MEMORY_WORDS[0]}${String(holderMb)}${LOST_MEMORY_WORDS[1]}`;
|
|
82
114
|
/** Why a job is set aside: no worker of the deployment may hold what it needs. */
|
|
83
115
|
var setAsideError = (needsMb, ceilingMb) => `${SET_ASIDE_WORDS[0]}${String(needsMb - 1)}${SET_ASIDE_WORDS[1]}${String(ceilingMb)}${SET_ASIDE_WORDS[2]}`;
|
|
116
|
+
// src/engine/jobs/waitingRules.ts
|
|
117
|
+
/**
|
|
118
|
+
* What an operator does to the jobs that have not started, at once — the in-process stores' half of `cancelWaiting` and
|
|
119
|
+
* `resumeWaiting` (`queueRules`), over the jobs those keep and the instant their clock reads.
|
|
120
|
+
*/
|
|
121
|
+
/** A job set aside, back in the queue at `at`: one set aside after failing every attempt has them all again. */
|
|
122
|
+
var putBack = (job, at) => {
|
|
123
|
+
job.status = "pending";
|
|
124
|
+
job.runAt = at;
|
|
125
|
+
job.updatedAt = at;
|
|
126
|
+
if (job.attempts >= job.maxAttempts) job.attempts = 0;
|
|
127
|
+
};
|
|
128
|
+
var named = (job, kind, name) => (kind === void 0 || job.target.kind === kind) && (name === void 0 || job.target.name === name);
|
|
129
|
+
var cancelWaitingIn = (jobs, { spaceIds, status, kind, name }, at) => {
|
|
130
|
+
const dropped = {
|
|
131
|
+
cancelled: 0,
|
|
132
|
+
functionJobs: []
|
|
133
|
+
};
|
|
134
|
+
for (const job of jobs) if (spaceIds.includes(job.spaceId) && (job.status === "pending" || job.status === "paused") && (status === void 0 || job.status === status) && named(job, kind, name)) {
|
|
135
|
+
job.status = "cancelled";
|
|
136
|
+
job.workerId = void 0;
|
|
137
|
+
job.pauseRequested = void 0;
|
|
138
|
+
job.updatedAt = at;
|
|
139
|
+
dropped.cancelled += 1;
|
|
140
|
+
if (job.target.kind === "function") dropped.functionJobs.push(job.id);
|
|
141
|
+
}
|
|
142
|
+
return dropped;
|
|
143
|
+
};
|
|
144
|
+
var resumeWaitingIn = (jobs, { spaceIds, kind, name }, at) => {
|
|
145
|
+
const put = {
|
|
146
|
+
resumed: 0,
|
|
147
|
+
functionJobs: []
|
|
148
|
+
};
|
|
149
|
+
for (const job of jobs) if (spaceIds.includes(job.spaceId) && job.status === "paused" && named(job, kind, name)) {
|
|
150
|
+
putBack(job, at);
|
|
151
|
+
put.resumed += 1;
|
|
152
|
+
if (job.target.kind === "function") put.functionJobs.push(job.id);
|
|
153
|
+
}
|
|
154
|
+
return put;
|
|
155
|
+
};
|
|
84
156
|
// src/engine/jobs/queueRules.ts
|
|
85
157
|
/** The kind of work a job is (`JobTake`): what a claim's `takes` picks by. */
|
|
86
158
|
var takeOf = (target) => target.kind === "function" ? "functionJobs" : target.code ? "codeActions" : "light";
|
|
@@ -91,8 +163,11 @@ var takesSpace = (spaces, spaceId) => !spaces || ("only" in spaces ? spaces.only
|
|
|
91
163
|
* whatever spaces it is kept for: the larger workers are few, and the job's own space's may all be the size that died.
|
|
92
164
|
*/
|
|
93
165
|
var fits = (job, spaces, memory) => job.needsMemoryMb === void 0 ? takesSpace(spaces, job.spaceId) : memory !== void 0 && memory.takesNeeding !== false && memory.mb >= job.needsMemoryMb;
|
|
94
|
-
/** Whether what `cancelWaiting` answered says it
|
|
95
|
-
var
|
|
166
|
+
/** Whether what `cancelWaiting` or `resumeWaiting` answered says it moved a job: its count under `field`. */
|
|
167
|
+
var movedSome = (answer, field) => {
|
|
168
|
+
const moved = isRecord(answer) ? answer[field] : void 0;
|
|
169
|
+
return typeof moved === "number" && moved > 0;
|
|
170
|
+
};
|
|
96
171
|
/**
|
|
97
172
|
* Whether a call changed the state, by its method and what it answered — what a store keeping the state elsewhere writes
|
|
98
173
|
* back after. A worker claims every second: a claim that took nothing, a refused `write` or `cancel` change nothing, and
|
|
@@ -109,7 +184,8 @@ var changedBy = (method, answer) => {
|
|
|
109
184
|
case "pause":
|
|
110
185
|
case "resume": return answer === true;
|
|
111
186
|
case "cancelPending": return typeof answer === "number" && answer > 0;
|
|
112
|
-
case "cancelWaiting": return
|
|
187
|
+
case "cancelWaiting": return movedSome(answer, "cancelled");
|
|
188
|
+
case "resumeWaiting": return movedSome(answer, "resumed");
|
|
113
189
|
case "heartbeat":
|
|
114
190
|
case "settle":
|
|
115
191
|
case "putSchedules": return true;
|
|
@@ -130,6 +206,8 @@ var queueRules = ({ jobs, schedules }, { retainFinished, clock, onUnansweredChan
|
|
|
130
206
|
const job = jobs.get(jobId);
|
|
131
207
|
return job && spaceIds.includes(job.spaceId) ? job : void 0;
|
|
132
208
|
};
|
|
209
|
+
/** What `listJobs` and `listJobGroups` read: the jobs a query names, the most recently touched first. */
|
|
210
|
+
const listed = ({ spaceIds, name, status, kind }) => [...jobs.values()].filter((job) => spaceIds.includes(job.spaceId) && (name === void 0 || job.target.name === name) && (status === void 0 || job.status === status) && (kind === void 0 || job.target.kind === kind)).sort((a, b) => b.updatedAt - a.updatedAt);
|
|
133
211
|
/** Numbered by the history itself, not by `attempts`: an operator who repeats a finished job starts its attempt
|
|
134
212
|
* count again, and the record of what has already been tried must not start again with it. */
|
|
135
213
|
const appendAttempt = (job, attempt) => {
|
|
@@ -285,13 +363,22 @@ var queueRules = ({ jobs, schedules }, { retainFinished, clock, onUnansweredChan
|
|
|
285
363
|
});
|
|
286
364
|
}
|
|
287
365
|
},
|
|
288
|
-
listJobs: (
|
|
289
|
-
const matching =
|
|
366
|
+
listJobs: (query) => {
|
|
367
|
+
const matching = listed(query);
|
|
290
368
|
return {
|
|
291
|
-
jobs: matching.slice(offset, offset + limit).map((job) => ({ ...job })),
|
|
369
|
+
jobs: matching.slice(query.offset, query.offset + query.limit).map((job) => ({ ...job })),
|
|
292
370
|
total: matching.length
|
|
293
371
|
};
|
|
294
372
|
},
|
|
373
|
+
listJobGroups: (query) => {
|
|
374
|
+
const matching = listed(query);
|
|
375
|
+
const groups = groupJobs(matching);
|
|
376
|
+
return {
|
|
377
|
+
groups: groups.slice(query.offset, query.offset + query.limit),
|
|
378
|
+
total: groups.length,
|
|
379
|
+
jobs: matching.length
|
|
380
|
+
};
|
|
381
|
+
},
|
|
295
382
|
listAcross: ({ statuses, limit, order, environment }) => [...jobs.values()].filter((job) => statuses.includes(job.status) && (environment === void 0 || job.environment === environment)).sort((a, b) => order === "due" ? a.runAt - b.runAt : b.updatedAt - a.updatedAt).slice(0, limit).map((job) => ({ ...job })),
|
|
296
383
|
summarize: ({ spaces = 10 } = {}) => summarizeJobs([...jobs.values()], spaces),
|
|
297
384
|
countDue: ({ spaces, memoryMb } = {}) => {
|
|
@@ -348,10 +435,7 @@ var queueRules = ({ jobs, schedules }, { retainFinished, clock, onUnansweredChan
|
|
|
348
435
|
resume: (spaceIds, jobId) => {
|
|
349
436
|
const job = owned(spaceIds, jobId);
|
|
350
437
|
if (job?.status !== "paused") return false;
|
|
351
|
-
job
|
|
352
|
-
job.runAt = now();
|
|
353
|
-
job.updatedAt = now();
|
|
354
|
-
if (job.attempts >= job.maxAttempts) job.attempts = 0;
|
|
438
|
+
putBack(job, now());
|
|
355
439
|
return true;
|
|
356
440
|
},
|
|
357
441
|
cancelPending: ({ spaceId, key, olderThan }) => {
|
|
@@ -366,22 +450,8 @@ var queueRules = ({ jobs, schedules }, { retainFinished, clock, onUnansweredChan
|
|
|
366
450
|
}
|
|
367
451
|
return dropped;
|
|
368
452
|
},
|
|
369
|
-
cancelWaiting: (
|
|
370
|
-
|
|
371
|
-
const dropped = {
|
|
372
|
-
cancelled: 0,
|
|
373
|
-
functionJobs: []
|
|
374
|
-
};
|
|
375
|
-
for (const job of jobs.values()) if (spaceIds.includes(job.spaceId) && (job.status === "pending" || job.status === "paused") && (status === void 0 || job.status === status) && (kind === void 0 || job.target.kind === kind) && (name === void 0 || job.target.name === name)) {
|
|
376
|
-
job.status = "cancelled";
|
|
377
|
-
job.workerId = void 0;
|
|
378
|
-
job.pauseRequested = void 0;
|
|
379
|
-
job.updatedAt = at;
|
|
380
|
-
dropped.cancelled += 1;
|
|
381
|
-
if (job.target.kind === "function") dropped.functionJobs.push(job.id);
|
|
382
|
-
}
|
|
383
|
-
return dropped;
|
|
384
|
-
}
|
|
453
|
+
cancelWaiting: (query) => cancelWaitingIn(jobs.values(), query, now()),
|
|
454
|
+
resumeWaiting: (query) => resumeWaitingIn(jobs.values(), query, now())
|
|
385
455
|
};
|
|
386
456
|
};
|
|
387
457
|
/** A state with nothing in it. */
|
|
@@ -520,6 +590,7 @@ var queueOver = (access) => ({
|
|
|
520
590
|
advanceSchedule: (...args) => access("advanceSchedule", args),
|
|
521
591
|
putSchedules: (...args) => access("putSchedules", args),
|
|
522
592
|
listJobs: (...args) => access("listJobs", args),
|
|
593
|
+
listJobGroups: (...args) => access("listJobGroups", args),
|
|
523
594
|
listAcross: (...args) => access("listAcross", args),
|
|
524
595
|
summarize: (...args) => access("summarize", args),
|
|
525
596
|
countDue: (...args) => access("countDue", args),
|
|
@@ -531,6 +602,7 @@ var queueOver = (access) => ({
|
|
|
531
602
|
pause: (...args) => access("pause", args),
|
|
532
603
|
resume: (...args) => access("resume", args),
|
|
533
604
|
cancelPending: (...args) => access("cancelPending", args),
|
|
534
|
-
cancelWaiting: (...args) => access("cancelWaiting", args)
|
|
605
|
+
cancelWaiting: (...args) => access("cancelWaiting", args),
|
|
606
|
+
resumeWaiting: (...args) => access("resumeWaiting", args)
|
|
535
607
|
});
|
|
536
608
|
export { flowOf as _, emptyState as a, scheduleKey as c, LOST_ERROR as d, LOST_MEMORY_WORDS as f, outgrewWorker as g, needsAfterLoss as h, changedBy as i, statusCounts as l, lostError as m, WAITING_STATUSES as n, queueOver as o, SET_ASIDE_WORDS as p, applyRule as r, queueRules as s, NEEDING_STATUSES as t, waitingKindOf as u };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JobGroup } from '../../types';
|
|
2
|
+
import { Job } from '@plitzi/sdk-shared';
|
|
3
|
+
/**
|
|
4
|
+
* Jobs, the most recently touched first, as `JobQueue.listJobGroups` answers them: a group per space, work and status,
|
|
5
|
+
* in the order their latest jobs come — what the in-process stores' rules (`queueRules`) page.
|
|
6
|
+
*/
|
|
7
|
+
export declare const groupJobs: (newestFirst: readonly Job[]) => JobGroup[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JobsDropped, JobsResumed, JobsToDrop, JobsToResume } from '../../types';
|
|
2
|
+
import { Job } from '@plitzi/sdk-shared';
|
|
3
|
+
/**
|
|
4
|
+
* What an operator does to the jobs that have not started, at once — the in-process stores' half of `cancelWaiting` and
|
|
5
|
+
* `resumeWaiting` (`queueRules`), over the jobs those keep and the instant their clock reads.
|
|
6
|
+
*/
|
|
7
|
+
/** A job set aside, back in the queue at `at`: one set aside after failing every attempt has them all again. */
|
|
8
|
+
export declare const putBack: (job: Job, at: number) => void;
|
|
9
|
+
export declare const cancelWaitingIn: (jobs: Iterable<Job>, { spaceIds, status, kind, name }: JobsToDrop, at: number) => JobsDropped;
|
|
10
|
+
export declare const resumeWaitingIn: (jobs: Iterable<Job>, { spaceIds, kind, name }: JobsToResume, at: number) => JobsResumed;
|
|
@@ -13,4 +13,4 @@ export declare const readsFlags: (document: object) => boolean;
|
|
|
13
13
|
* environment and visitor, then the server's own layer and a tester's forced one — the same order a page resolves
|
|
14
14
|
* them in. A run has no URL, so a rule on the host or the route does not match here.
|
|
15
15
|
*/
|
|
16
|
-
export declare const flagsForRun: (config: Pick<ActionsConfig, "lookups" | "flags">, request: Pick<ActionRunRequest, "entry" | "spaceId" | "environment" | "at" | "user" | "forcedFlags">) => Promise<Record<string, boolean>>;
|
|
16
|
+
export declare const flagsForRun: (config: Pick<ActionsConfig, "lookups" | "flags">, request: Pick<ActionRunRequest, "entry" | "spaceId" | "environment" | "at" | "user" | "forcedFlags" | "rolloutBuckets">) => Promise<Record<string, boolean>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActionKvAdapter } from '../types';
|
|
1
2
|
import { MemoryReading } from '@plitzi/sdk-kernel/stats';
|
|
2
3
|
import { ActionCallResult } from '@plitzi/sdk-shared';
|
|
3
4
|
/**
|
|
@@ -44,16 +45,11 @@ export type ActiveRun = {
|
|
|
44
45
|
* The half of a key/value store the guards need, and nothing more.
|
|
45
46
|
*
|
|
46
47
|
* The same methods `ActionKvAdapter` already declares, so a deployment that configured `action.kv` has already
|
|
47
|
-
* provided this: no second store to stand up, and no adapter change. `
|
|
48
|
-
*
|
|
48
|
+
* provided this: no second store to stand up, and no adapter change. `swap` is what takes a single-flight key — written
|
|
49
|
+
* where none is, with its lifetime, at once; `get`/`set` are what carry a cancellation and a replayable answer between
|
|
50
|
+
* replicas.
|
|
49
51
|
*/
|
|
50
|
-
export type RunKeyStore =
|
|
51
|
-
get: (key: string) => Promise<string | undefined>;
|
|
52
|
-
set: (key: string, value: string, ttlSeconds?: number) => Promise<void>;
|
|
53
|
-
increment: (key: string, amount: number) => Promise<number>;
|
|
54
|
-
expire: (key: string, ttlSeconds: number) => Promise<void>;
|
|
55
|
-
delete: (key: string) => Promise<void>;
|
|
56
|
-
};
|
|
52
|
+
export type RunKeyStore = Pick<ActionKvAdapter, 'get' | 'set' | 'swap' | 'delete'>;
|
|
57
53
|
export type RunGuardsConfig = {
|
|
58
54
|
/**
|
|
59
55
|
* Concurrent CALLS one space may have in flight — its fair share of the process: a job worker gives it more of the
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -413,6 +413,11 @@ export type ActionRunRequest = {
|
|
|
413
413
|
* `flags` say: those are the browser's claim, and a flow does not take a claim as a fact.
|
|
414
414
|
*/
|
|
415
415
|
forcedFlags?: Record<string, boolean>;
|
|
416
|
+
/**
|
|
417
|
+
* Where the visitor who started the run stands in the space's gradual rollouts — their places, from their cookie — so
|
|
418
|
+
* a flow sees a rolled-out flag as the page that called it was drawn with. None, a rollout's flag answers its own value.
|
|
419
|
+
*/
|
|
420
|
+
rolloutBuckets?: Record<string, number>;
|
|
416
421
|
emit?: (chunk: unknown) => void;
|
|
417
422
|
/** Reports each step as it settles, for a caller watching the run happen. Absent for a plain request/response. */
|
|
418
423
|
onNode?: (id: string, status: InteractionNodeStatus) => void;
|
package/dist/functions/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as oauthCallbackUrlOn, d as DEFAULT_FUNCTION_LIMITS, i as buildFunctions, l as readManifest, n as functionsInHand, o as DEFAULT_FUNCTION_JOB_LIMITS, r as FunctionsBuildError, t as createActionsModule, u as DEFAULT_FUNCTION_CEILINGS } from "../chunks/module-
|
|
2
|
-
import { i as readFunctionsDir, n as loadFunctions, r as loadFunctionsSource } from "../chunks/load-
|
|
1
|
+
import { c as oauthCallbackUrlOn, d as DEFAULT_FUNCTION_LIMITS, i as buildFunctions, l as readManifest, n as functionsInHand, o as DEFAULT_FUNCTION_JOB_LIMITS, r as FunctionsBuildError, t as createActionsModule, u as DEFAULT_FUNCTION_CEILINGS } from "../chunks/module-Baod2T6h.mjs";
|
|
2
|
+
import { i as readFunctionsDir, n as loadFunctions, r as loadFunctionsSource } from "../chunks/load-tw8iAgZy.mjs";
|
|
3
3
|
import { t as credentialsFromEnv } from "../chunks/credentials-DwxZeAvH.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { FUNCTIONS_PROTOCOL, FunctionFailure, failedAnswerOf, readResponseMessage } from "@plitzi/sdk-shared/functions";
|
|
@@ -13,10 +13,10 @@ export type JobControlOptions = {
|
|
|
13
13
|
kv: ActionKvAdapter;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export type JobControl = Pick<JobQueue, 'pause' | 'resume' | 'cancel' | 'requeue' | 'cancelWaiting'>;
|
|
16
|
+
export type JobControl = Pick<JobQueue, 'pause' | 'resume' | 'cancel' | 'requeue' | 'cancelWaiting' | 'resumeWaiting'>;
|
|
17
17
|
/**
|
|
18
18
|
* An operator's hold on the jobs, from a process that serves no pages — a deployment's API behind its Queue panel: the
|
|
19
|
-
* queue's own `pause`, `resume`, `cancel`, `requeue` and `
|
|
20
|
-
* of the spaces' functions, as the page server says it when its code does the same.
|
|
19
|
+
* queue's own `pause`, `resume`, `cancel`, `requeue`, `cancelWaiting` and `resumeWaiting`, each said on `$job:<id>` when it
|
|
20
|
+
* changed a job of the spaces' functions, as the page server says it when its code does the same.
|
|
21
21
|
*/
|
|
22
22
|
export declare const createJobControl: ({ queue, realtime }: JobControlOptions) => JobControl;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as schedulesFor, C as fleetJobQueue, D as DEFAULT_MAX_ATTEMPTS, E as createScheduler, I as fetchConnectorRecords, L as rebaseMedia, M as KEPT_CALLS_PER_SPACE, N as KEPT_CALL_MS, O as scheduleFor, R as writeConnectorRecord, T as createJobWorker, _ as DEFAULT_LIMITS, a as createTaskRegistry, b as MAX_LIST_ENTRIES, f as taskName, g as spaceKvPatterns, j as createMemoryJobQueue, k as scheduleJobId, m as createSigning, p as MIN_SIGNING_SECRET_LENGTH, s as jobViewOf, t as createActionsModule, v as createKvStore, w as fleetKv, x as createActionJobs, y as MAX_LIST_BYTES } from "./chunks/module-
|
|
2
|
-
import { n as describeTask, r as createConnectorResolver, t as describeCatalog } from "./chunks/taskCatalog-
|
|
3
|
-
import { n as stateOf, t as documentOf } from "./chunks/queueDocument-
|
|
4
|
-
import { a as emptyState, i as changedBy, l as statusCounts, o as queueOver, r as applyRule, s as queueRules } from "./chunks/queueRules-
|
|
1
|
+
import { A as schedulesFor, C as fleetJobQueue, D as DEFAULT_MAX_ATTEMPTS, E as createScheduler, I as fetchConnectorRecords, L as rebaseMedia, M as KEPT_CALLS_PER_SPACE, N as KEPT_CALL_MS, O as scheduleFor, R as writeConnectorRecord, T as createJobWorker, _ as DEFAULT_LIMITS, a as createTaskRegistry, b as MAX_LIST_ENTRIES, f as taskName, g as spaceKvPatterns, j as createMemoryJobQueue, k as scheduleJobId, m as createSigning, p as MIN_SIGNING_SECRET_LENGTH, s as jobViewOf, t as createActionsModule, v as createKvStore, w as fleetKv, x as createActionJobs, y as MAX_LIST_BYTES } from "./chunks/module-Baod2T6h.mjs";
|
|
2
|
+
import { n as describeTask, r as createConnectorResolver, t as describeCatalog } from "./chunks/taskCatalog-J9hBMCsz.mjs";
|
|
3
|
+
import { n as stateOf, t as documentOf } from "./chunks/queueDocument-DCBWcxe_.mjs";
|
|
4
|
+
import { a as emptyState, i as changedBy, l as statusCounts, o as queueOver, r as applyRule, s as queueRules } from "./chunks/queueRules-UGZNkho0.mjs";
|
|
5
5
|
import { a as triggerParams, t as ActionRunError } from "./chunks/errors-bCBfIe7c.mjs";
|
|
6
6
|
import { a as createMapKv, o as createMemoryKv } from "./chunks/grants-BsD-WlLE.mjs";
|
|
7
7
|
import { createActionRealtime, n as publishJobView, r as createRealtimeHub, t as createRealtimeRetained } from "./realtime/index.mjs";
|
|
@@ -507,12 +507,12 @@ var createRedisKv = (client, { prefix = "" } = {}) => {
|
|
|
507
507
|
};
|
|
508
508
|
};
|
|
509
509
|
// src/functions/jobControl.ts
|
|
510
|
-
/** How many of the jobs
|
|
510
|
+
/** How many of the jobs moved at once (`cancelWaiting`, `resumeWaiting`) have their watchers told at a time. */
|
|
511
511
|
var ANNOUNCED_AT_ONCE = 20;
|
|
512
512
|
/**
|
|
513
513
|
* An operator's hold on the jobs, from a process that serves no pages — a deployment's API behind its Queue panel: the
|
|
514
|
-
* queue's own `pause`, `resume`, `cancel`, `requeue` and `
|
|
515
|
-
* of the spaces' functions, as the page server says it when its code does the same.
|
|
514
|
+
* queue's own `pause`, `resume`, `cancel`, `requeue`, `cancelWaiting` and `resumeWaiting`, each said on `$job:<id>` when it
|
|
515
|
+
* changed a job of the spaces' functions, as the page server says it when its code does the same.
|
|
516
516
|
*/
|
|
517
517
|
var createJobControl = ({ queue, realtime }) => {
|
|
518
518
|
const said = realtime ? {
|
|
@@ -537,6 +537,9 @@ var createJobControl = ({ queue, realtime }) => {
|
|
|
537
537
|
if (changed) await announce(spaceIds, jobId);
|
|
538
538
|
return changed;
|
|
539
539
|
};
|
|
540
|
+
const announceAll = async (spaceIds, jobIds) => {
|
|
541
|
+
for (let from = 0; from < jobIds.length; from += ANNOUNCED_AT_ONCE) await Promise.all(jobIds.slice(from, from + ANNOUNCED_AT_ONCE).map((jobId) => announce(spaceIds, jobId)));
|
|
542
|
+
};
|
|
540
543
|
return {
|
|
541
544
|
pause: told((spaceIds, jobId) => queue.pause(spaceIds, jobId)),
|
|
542
545
|
resume: told((spaceIds, jobId) => queue.resume(spaceIds, jobId)),
|
|
@@ -544,8 +547,13 @@ var createJobControl = ({ queue, realtime }) => {
|
|
|
544
547
|
requeue: told((spaceIds, jobId, options) => queue.requeue(spaceIds, jobId, options)),
|
|
545
548
|
cancelWaiting: async (query) => {
|
|
546
549
|
const dropped = await queue.cancelWaiting(query);
|
|
547
|
-
|
|
550
|
+
await announceAll(query.spaceIds, dropped.functionJobs);
|
|
548
551
|
return dropped;
|
|
552
|
+
},
|
|
553
|
+
resumeWaiting: async (query) => {
|
|
554
|
+
const resumed = await queue.resumeWaiting(query);
|
|
555
|
+
await announceAll(query.spaceIds, resumed.functionJobs);
|
|
556
|
+
return resumed;
|
|
549
557
|
}
|
|
550
558
|
};
|
|
551
559
|
};
|
package/dist/mongo/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as flowOf, d as LOST_ERROR, f as LOST_MEMORY_WORDS, l as statusCounts, n as WAITING_STATUSES, p as SET_ASIDE_WORDS, t as NEEDING_STATUSES, u as waitingKindOf } from "../chunks/queueRules-
|
|
1
|
+
import { _ as flowOf, d as LOST_ERROR, f as LOST_MEMORY_WORDS, l as statusCounts, n as WAITING_STATUSES, p as SET_ASIDE_WORDS, t as NEEDING_STATUSES, u as waitingKindOf } from "../chunks/queueRules-UGZNkho0.mjs";
|
|
2
2
|
import { t as createStoreClock } from "../chunks/storeClock-Btm7EaVm.mjs";
|
|
3
3
|
import { TERMINAL_JOB_STATUSES } from "@plitzi/sdk-shared/actions";
|
|
4
4
|
// src/mongo/claimable.ts
|
|
@@ -56,6 +56,95 @@ var dropWaiting = async (jobs, { spaceIds, status, kind, name }, at, expiresAt)
|
|
|
56
56
|
functionJobs: watched.map((job) => job._id)
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
+
// src/mongo/jobLists.ts
|
|
60
|
+
/** The jobs a list names (`listJobs`, `listJobGroups`). */
|
|
61
|
+
var listFilter = ({ spaceIds, name, status, kind }) => ({
|
|
62
|
+
spaceId: { $in: spaceIds },
|
|
63
|
+
...name ? { "target.name": name } : {},
|
|
64
|
+
...status ? { status } : {},
|
|
65
|
+
...kind ? { "target.kind": kind } : {}
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* `JobQueue.listJobGroups` over the jobs' collection, in one pass — the page and the count alike: a group per space,
|
|
69
|
+
* work and status, the one of the most recently touched job first. What a job of the functions saved is left out before
|
|
70
|
+
* the grouping: up to megabytes per job, and no row shows it.
|
|
71
|
+
*/
|
|
72
|
+
var listJobGroupsOf = async (jobs, query) => {
|
|
73
|
+
const [found] = await jobs.aggregate([
|
|
74
|
+
{ $match: listFilter(query) },
|
|
75
|
+
{ $project: { state: 0 } },
|
|
76
|
+
{ $sort: {
|
|
77
|
+
updatedAt: -1,
|
|
78
|
+
_id: -1
|
|
79
|
+
} },
|
|
80
|
+
{ $group: {
|
|
81
|
+
_id: {
|
|
82
|
+
spaceId: "$spaceId",
|
|
83
|
+
kind: "$target.kind",
|
|
84
|
+
name: "$target.name",
|
|
85
|
+
status: "$status"
|
|
86
|
+
},
|
|
87
|
+
latest: { $first: "$$ROOT" },
|
|
88
|
+
count: { $sum: 1 },
|
|
89
|
+
firstDueAt: { $min: "$dueAt" },
|
|
90
|
+
lastDueAt: { $max: "$dueAt" }
|
|
91
|
+
} },
|
|
92
|
+
{ $sort: {
|
|
93
|
+
"latest.updatedAt": -1,
|
|
94
|
+
"latest._id": -1
|
|
95
|
+
} },
|
|
96
|
+
{ $facet: {
|
|
97
|
+
page: [
|
|
98
|
+
{ $skip: query.offset },
|
|
99
|
+
{ $limit: Math.max(1, query.limit) },
|
|
100
|
+
{ $project: { _id: 0 } }
|
|
101
|
+
],
|
|
102
|
+
total: [{ $group: {
|
|
103
|
+
_id: null,
|
|
104
|
+
groups: { $sum: 1 },
|
|
105
|
+
jobs: { $sum: "$count" }
|
|
106
|
+
} }]
|
|
107
|
+
} }
|
|
108
|
+
]).toArray();
|
|
109
|
+
const total = found.total.at(0);
|
|
110
|
+
return {
|
|
111
|
+
groups: found.page.slice(0, query.limit),
|
|
112
|
+
total: total?.groups ?? 0,
|
|
113
|
+
jobs: total?.jobs ?? 0
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
// src/mongo/resumeWaiting.ts
|
|
117
|
+
/**
|
|
118
|
+
* A job set aside, back in the queue at `at` (`resume`, `resumeWaiting`): one set aside after failing every attempt has
|
|
119
|
+
* them all again.
|
|
120
|
+
*/
|
|
121
|
+
var putBack = (at) => [{ $set: {
|
|
122
|
+
status: "pending",
|
|
123
|
+
runAt: at,
|
|
124
|
+
updatedAt: at,
|
|
125
|
+
attempts: { $cond: [
|
|
126
|
+
{ $gte: ["$attempts", "$maxAttempts"] },
|
|
127
|
+
0,
|
|
128
|
+
"$attempts"
|
|
129
|
+
] }
|
|
130
|
+
} }];
|
|
131
|
+
/** `JobQueue.resumeWaiting` over the jobs' collection: every job of these spaces set aside, back in one statement. */
|
|
132
|
+
var resumeWaiting = async (jobs, { spaceIds, kind, name }, at) => {
|
|
133
|
+
const filter = {
|
|
134
|
+
spaceId: { $in: spaceIds },
|
|
135
|
+
status: "paused",
|
|
136
|
+
...name ? { "target.name": name } : {},
|
|
137
|
+
...kind ? { "target.kind": kind } : {}
|
|
138
|
+
};
|
|
139
|
+
const watched = kind === "action" ? [] : await jobs.find({
|
|
140
|
+
...filter,
|
|
141
|
+
"target.kind": "function"
|
|
142
|
+
}, { projection: { _id: 1 } }).toArray();
|
|
143
|
+
return {
|
|
144
|
+
resumed: (await jobs.updateMany(filter, putBack(at))).modifiedCount,
|
|
145
|
+
functionJobs: watched.map((job) => job._id)
|
|
146
|
+
};
|
|
147
|
+
};
|
|
59
148
|
// src/mongo/jobQueue.ts
|
|
60
149
|
/** Mongo's code for a unique index that refused a second document with the same key. */
|
|
61
150
|
var DUPLICATE_KEY$1 = 11e3;
|
|
@@ -420,23 +509,29 @@ var createMongoJobQueue = ({ db, collections: names = {}, retentionDays = 90 })
|
|
|
420
509
|
actionId: { $nin: incoming.map((schedule) => schedule.actionId) }
|
|
421
510
|
});
|
|
422
511
|
},
|
|
423
|
-
listJobs: async (
|
|
512
|
+
listJobs: async (query) => {
|
|
424
513
|
const { jobs } = await collections();
|
|
425
|
-
const filter =
|
|
426
|
-
spaceId: { $in: spaceIds },
|
|
427
|
-
...name ? { "target.name": name } : {},
|
|
428
|
-
...status ? { status } : {},
|
|
429
|
-
...kind ? { "target.kind": kind } : {}
|
|
430
|
-
};
|
|
514
|
+
const filter = listFilter(query);
|
|
431
515
|
const [found, total] = await Promise.all([jobs.find(filter).sort({
|
|
432
516
|
updatedAt: -1,
|
|
433
517
|
_id: -1
|
|
434
|
-
}).skip(offset).limit(limit).toArray(), jobs.countDocuments(filter)]);
|
|
518
|
+
}).skip(query.offset).limit(query.limit).toArray(), jobs.countDocuments(filter)]);
|
|
435
519
|
return {
|
|
436
520
|
jobs: found.map(toJob),
|
|
437
521
|
total
|
|
438
522
|
};
|
|
439
523
|
},
|
|
524
|
+
listJobGroups: async (query) => {
|
|
525
|
+
const { jobs } = await collections();
|
|
526
|
+
const { groups, ...counted } = await listJobGroupsOf(jobs, query);
|
|
527
|
+
return {
|
|
528
|
+
...counted,
|
|
529
|
+
groups: groups.map(({ latest, ...group }) => ({
|
|
530
|
+
...group,
|
|
531
|
+
latest: toJob(latest)
|
|
532
|
+
}))
|
|
533
|
+
};
|
|
534
|
+
},
|
|
440
535
|
listAcross: async ({ statuses, limit, order, environment }) => {
|
|
441
536
|
const { jobs } = await collections();
|
|
442
537
|
return (await jobs.find({
|
|
@@ -652,16 +747,7 @@ var createMongoJobQueue = ({ db, collections: names = {}, retentionDays = 90 })
|
|
|
652
747
|
_id: jobId,
|
|
653
748
|
spaceId: { $in: spaceIds },
|
|
654
749
|
status: "paused"
|
|
655
|
-
},
|
|
656
|
-
status: "pending",
|
|
657
|
-
runAt: at,
|
|
658
|
-
updatedAt: at,
|
|
659
|
-
attempts: { $cond: [
|
|
660
|
-
{ $gte: ["$attempts", "$maxAttempts"] },
|
|
661
|
-
0,
|
|
662
|
-
"$attempts"
|
|
663
|
-
] }
|
|
664
|
-
} }])).matchedCount === 1;
|
|
750
|
+
}, putBack(at))).matchedCount === 1;
|
|
665
751
|
},
|
|
666
752
|
cancelPending: async ({ spaceId, key, olderThan }) => {
|
|
667
753
|
const { jobs } = await collections();
|
|
@@ -688,6 +774,10 @@ var createMongoJobQueue = ({ db, collections: names = {}, retentionDays = 90 })
|
|
|
688
774
|
const { jobs } = await collections();
|
|
689
775
|
const at = await clock.now();
|
|
690
776
|
return dropWaiting(jobs, query, at, expiryOf(at));
|
|
777
|
+
},
|
|
778
|
+
resumeWaiting: async (query) => {
|
|
779
|
+
const { jobs } = await collections();
|
|
780
|
+
return resumeWaiting(jobs, query, await clock.now());
|
|
691
781
|
}
|
|
692
782
|
};
|
|
693
783
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JobDocument } from './jobQueue';
|
|
2
|
+
import { JobGroup, JobQuery } from '../types';
|
|
3
|
+
import { Collection, Filter } from 'mongodb';
|
|
4
|
+
/** The jobs a list names (`listJobs`, `listJobGroups`). */
|
|
5
|
+
export declare const listFilter: ({ spaceIds, name, status, kind }: JobQuery) => Filter<JobDocument>;
|
|
6
|
+
/** A group as the collection answers it: its latest job still a document. */
|
|
7
|
+
export type JobGroupDocument = Omit<JobGroup, 'latest'> & {
|
|
8
|
+
latest: JobDocument;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `JobQueue.listJobGroups` over the jobs' collection, in one pass — the page and the count alike: a group per space,
|
|
12
|
+
* work and status, the one of the most recently touched job first. What a job of the functions saved is left out before
|
|
13
|
+
* the grouping: up to megabytes per job, and no row shows it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const listJobGroupsOf: (jobs: Collection<JobDocument>, query: JobQuery) => Promise<{
|
|
16
|
+
groups: JobGroupDocument[];
|
|
17
|
+
total: number;
|
|
18
|
+
jobs: number;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JobDocument } from './jobQueue';
|
|
2
|
+
import { JobsResumed, JobsToResume } from '../types';
|
|
3
|
+
import { Collection, Document } from 'mongodb';
|
|
4
|
+
/**
|
|
5
|
+
* A job set aside, back in the queue at `at` (`resume`, `resumeWaiting`): one set aside after failing every attempt has
|
|
6
|
+
* them all again.
|
|
7
|
+
*/
|
|
8
|
+
export declare const putBack: (at: number) => Document[];
|
|
9
|
+
/** `JobQueue.resumeWaiting` over the jobs' collection: every job of these spaces set aside, back in one statement. */
|
|
10
|
+
export declare const resumeWaiting: (jobs: Collection<JobDocument>, { spaceIds, kind, name }: JobsToResume, at: number) => Promise<JobsResumed>;
|
package/dist/mysql/index.mjs
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
|
-
import { _ as flowOf, d as LOST_ERROR, g as outgrewWorker, h as needsAfterLoss, l as statusCounts, m as lostError, p as SET_ASIDE_WORDS, u as waitingKindOf } from "../chunks/queueRules-
|
|
1
|
+
import { _ as flowOf, d as LOST_ERROR, g as outgrewWorker, h as needsAfterLoss, l as statusCounts, m as lostError, p as SET_ASIDE_WORDS, u as waitingKindOf } from "../chunks/queueRules-UGZNkho0.mjs";
|
|
2
2
|
import { t as createStoreClock } from "../chunks/storeClock-Btm7EaVm.mjs";
|
|
3
3
|
import { TERMINAL_JOB_STATUSES } from "@plitzi/sdk-shared/actions";
|
|
4
4
|
import { execute, selectOne, selectRows } from "@plitzi/sdk-kernel/mysql";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A job's row as a list reads it: every column but what a job of the functions saved (`state`, up to megabytes, and no
|
|
7
|
+
* list shows it) — read as NULL, so `toJob` reads it as none.
|
|
8
|
+
*/
|
|
9
|
+
var LISTED_JOB_COLUMNS = [...Object.keys({
|
|
10
|
+
id: true,
|
|
11
|
+
space_id: true,
|
|
12
|
+
target_kind: true,
|
|
13
|
+
target_name: true,
|
|
14
|
+
target: true,
|
|
15
|
+
environment: true,
|
|
16
|
+
input: true,
|
|
17
|
+
due_at: true,
|
|
18
|
+
max_attempts: true,
|
|
19
|
+
missed: true,
|
|
20
|
+
job_key: true,
|
|
21
|
+
status: true,
|
|
22
|
+
run_at: true,
|
|
23
|
+
attempts: true,
|
|
24
|
+
lease_until: true,
|
|
25
|
+
worker_id: true,
|
|
26
|
+
run_id: true,
|
|
27
|
+
cancel_requested: true,
|
|
28
|
+
created_at: true,
|
|
29
|
+
updated_at: true,
|
|
30
|
+
error: true,
|
|
31
|
+
history: true,
|
|
32
|
+
state: true,
|
|
33
|
+
progress: true,
|
|
34
|
+
result: true,
|
|
35
|
+
pause_requested: true,
|
|
36
|
+
active_ms: true,
|
|
37
|
+
holder_memory_mb: true,
|
|
38
|
+
needs_memory_mb: true,
|
|
39
|
+
near_memory_limit: true
|
|
40
|
+
}).filter((column) => column !== "state"), "NULL AS state"].join(", ");
|
|
6
41
|
/**
|
|
7
42
|
* A row as the contract shapes it.
|
|
8
43
|
*
|
|
@@ -79,6 +114,89 @@ var claimable = (at, spaces, memoryMb, takes) => {
|
|
|
79
114
|
]
|
|
80
115
|
};
|
|
81
116
|
};
|
|
117
|
+
// src/mysql/jobLists.ts
|
|
118
|
+
/** Digits an epoch-ms `updated_at` is padded to, so its text sorts as the number does. */
|
|
119
|
+
var LATEST_PAD = 20;
|
|
120
|
+
/** The jobs a list names (`listJobs`, `listJobGroups`): the clause and its parameters. */
|
|
121
|
+
var listWhere = ({ spaceIds, name, status, kind }) => ({
|
|
122
|
+
sql: [
|
|
123
|
+
"space_id IN (?)",
|
|
124
|
+
...name ? ["target_name = ?"] : [],
|
|
125
|
+
...status ? ["status = ?"] : [],
|
|
126
|
+
...kind ? ["target_kind = ?"] : []
|
|
127
|
+
].join(" AND "),
|
|
128
|
+
params: [
|
|
129
|
+
spaceIds,
|
|
130
|
+
...name ? [name] : [],
|
|
131
|
+
...status ? [status] : [],
|
|
132
|
+
...kind ? [kind] : []
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* `JobQueue.listJobGroups` over the jobs table: a group per space, work and status, the one of the most recently
|
|
137
|
+
* touched job first. Each group's latest job — by `updated_at`, then `id`, as `listJobs` orders them — is read off one
|
|
138
|
+
* MAX of the two written as one string: MySQL 5.7 has no window functions. A query naming no space is answered empty
|
|
139
|
+
* by the caller (`IN ()` is not SQL).
|
|
140
|
+
*/
|
|
141
|
+
var listJobGroupsOf = async (conn, table, query) => {
|
|
142
|
+
const where = listWhere(query);
|
|
143
|
+
const grouped = `FROM ${table} WHERE ${where.sql} GROUP BY space_id, target_kind, target_name, status`;
|
|
144
|
+
const [found, count] = await Promise.all([selectRows(conn, `SELECT MAX(CONCAT(LPAD(updated_at, ${String(LATEST_PAD)}, '0'), id)) AS latest, COUNT(*) AS n,
|
|
145
|
+
MIN(due_at) AS first_due, MAX(due_at) AS last_due
|
|
146
|
+
${grouped} ORDER BY latest DESC LIMIT ? OFFSET ?`, [
|
|
147
|
+
...where.params,
|
|
148
|
+
query.limit,
|
|
149
|
+
query.offset
|
|
150
|
+
]), selectOne(conn, `SELECT COUNT(*) AS total, SUM(n) AS jobs FROM (SELECT COUNT(*) AS n ${grouped}) AS g`, where.params)]);
|
|
151
|
+
const ids = found.map((group) => group.latest.slice(LATEST_PAD));
|
|
152
|
+
const rows = ids.length > 0 ? await selectRows(conn, `SELECT ${LISTED_JOB_COLUMNS} FROM ${table} WHERE id IN (?)`, [ids]) : [];
|
|
153
|
+
const latest = new Map(rows.map((row) => [row.id, toJob(row)]));
|
|
154
|
+
return {
|
|
155
|
+
groups: found.flatMap((group, at) => {
|
|
156
|
+
const job = latest.get(ids[at] ?? "");
|
|
157
|
+
return job ? [{
|
|
158
|
+
latest: job,
|
|
159
|
+
count: Number(group.n),
|
|
160
|
+
firstDueAt: Number(group.first_due),
|
|
161
|
+
lastDueAt: Number(group.last_due)
|
|
162
|
+
}] : [];
|
|
163
|
+
}),
|
|
164
|
+
total: Number(count?.total ?? 0),
|
|
165
|
+
jobs: Number(count?.jobs ?? 0)
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
// src/mysql/resumeWaiting.ts
|
|
169
|
+
/**
|
|
170
|
+
* A job set aside, back in the queue at the instant of the statement's first two parameters (`resume`,
|
|
171
|
+
* `resumeWaiting`): one set aside after failing every attempt has them all again.
|
|
172
|
+
*/
|
|
173
|
+
var PUT_BACK = "status = 'pending', run_at = ?, updated_at = ?, attempts = IF(attempts >= max_attempts, 0, attempts)";
|
|
174
|
+
/**
|
|
175
|
+
* `JobQueue.resumeWaiting` over the jobs table: every job of these spaces set aside, back in one statement. A query
|
|
176
|
+
* naming no space is answered empty by the caller (`IN ()` is not SQL).
|
|
177
|
+
*/
|
|
178
|
+
var resumeWaitingOf = async (conn, table, { spaceIds, kind, name }, at) => {
|
|
179
|
+
const where = [
|
|
180
|
+
"space_id IN (?)",
|
|
181
|
+
"status = 'paused'",
|
|
182
|
+
...name ? ["target_name = ?"] : [],
|
|
183
|
+
...kind ? ["target_kind = ?"] : []
|
|
184
|
+
].join(" AND ");
|
|
185
|
+
const params = [
|
|
186
|
+
spaceIds,
|
|
187
|
+
...name ? [name] : [],
|
|
188
|
+
...kind ? [kind] : []
|
|
189
|
+
];
|
|
190
|
+
const watched = kind === "action" ? [] : await selectRows(conn, `SELECT id FROM ${table} WHERE ${where} AND target_kind = 'function'`, params);
|
|
191
|
+
return {
|
|
192
|
+
resumed: (await execute(conn, `UPDATE ${table} SET ${PUT_BACK} WHERE ${where}`, [
|
|
193
|
+
at,
|
|
194
|
+
at,
|
|
195
|
+
...params
|
|
196
|
+
])).affectedRows,
|
|
197
|
+
functionJobs: watched.map((row) => row.id)
|
|
198
|
+
};
|
|
199
|
+
};
|
|
82
200
|
// src/mysql/schema.ts
|
|
83
201
|
var PREFIX = /^[A-Za-z0-9_]*$/;
|
|
84
202
|
/**
|
|
@@ -556,34 +674,28 @@ var createMysqlJobQueue = ({ pool, tablePrefix = "", createTables = true, retent
|
|
|
556
674
|
await execute(connection, kept.length > 0 ? `DELETE FROM ${t.schedules} WHERE space_id = ? AND action_id NOT IN (?)` : `DELETE FROM ${t.schedules} WHERE space_id = ?`, kept.length > 0 ? [spaceId, kept] : [spaceId]);
|
|
557
675
|
});
|
|
558
676
|
},
|
|
559
|
-
listJobs: async (
|
|
560
|
-
if (!inSpaces(spaceIds)) return {
|
|
677
|
+
listJobs: async (query) => {
|
|
678
|
+
if (!inSpaces(query.spaceIds)) return {
|
|
561
679
|
jobs: [],
|
|
562
680
|
total: 0
|
|
563
681
|
};
|
|
564
682
|
const conn = await db();
|
|
565
|
-
const where =
|
|
566
|
-
|
|
567
|
-
...
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
]
|
|
571
|
-
const params = [
|
|
572
|
-
spaceIds,
|
|
573
|
-
...name ? [name] : [],
|
|
574
|
-
...status ? [status] : [],
|
|
575
|
-
...kind ? [kind] : []
|
|
576
|
-
];
|
|
577
|
-
const [rows, count] = await Promise.all([selectRows(conn, `SELECT * FROM ${t.jobs} WHERE ${where} ORDER BY updated_at DESC, id DESC LIMIT ? OFFSET ?`, [
|
|
578
|
-
...params,
|
|
579
|
-
limit,
|
|
580
|
-
offset
|
|
581
|
-
]), selectOne(conn, `SELECT COUNT(*) AS total FROM ${t.jobs} WHERE ${where}`, params)]);
|
|
683
|
+
const where = listWhere(query);
|
|
684
|
+
const [rows, count] = await Promise.all([selectRows(conn, `SELECT * FROM ${t.jobs} WHERE ${where.sql} ORDER BY updated_at DESC, id DESC LIMIT ? OFFSET ?`, [
|
|
685
|
+
...where.params,
|
|
686
|
+
query.limit,
|
|
687
|
+
query.offset
|
|
688
|
+
]), selectOne(conn, `SELECT COUNT(*) AS total FROM ${t.jobs} WHERE ${where.sql}`, where.params)]);
|
|
582
689
|
return {
|
|
583
690
|
jobs: rows.map(toJob),
|
|
584
691
|
total: Number(count?.total ?? 0)
|
|
585
692
|
};
|
|
586
693
|
},
|
|
694
|
+
listJobGroups: async (query) => inSpaces(query.spaceIds) ? listJobGroupsOf(await db(), t.jobs, query) : {
|
|
695
|
+
groups: [],
|
|
696
|
+
total: 0,
|
|
697
|
+
jobs: 0
|
|
698
|
+
},
|
|
587
699
|
countDue: async ({ spaces, memoryMb } = {}) => {
|
|
588
700
|
const conn = await db();
|
|
589
701
|
const where = claimable(await clock.now(), spaces, memoryMb);
|
|
@@ -678,9 +790,7 @@ var createMysqlJobQueue = ({ pool, tablePrefix = "", createTables = true, retent
|
|
|
678
790
|
if (!inSpaces(spaceIds)) return false;
|
|
679
791
|
const conn = await db();
|
|
680
792
|
const at = await clock.now();
|
|
681
|
-
return (await execute(conn, `UPDATE ${t.jobs} SET
|
|
682
|
-
attempts = IF(attempts >= max_attempts, 0, attempts)
|
|
683
|
-
WHERE id = ? AND space_id IN (?) AND status = 'paused'`, [
|
|
793
|
+
return (await execute(conn, `UPDATE ${t.jobs} SET ${PUT_BACK} WHERE id = ? AND space_id IN (?) AND status = 'paused'`, [
|
|
684
794
|
at,
|
|
685
795
|
at,
|
|
686
796
|
jobId,
|
|
@@ -733,6 +843,10 @@ var createMysqlJobQueue = ({ pool, tablePrefix = "", createTables = true, retent
|
|
|
733
843
|
])).affectedRows,
|
|
734
844
|
functionJobs: watched.map((job) => job.id)
|
|
735
845
|
};
|
|
846
|
+
},
|
|
847
|
+
resumeWaiting: async (query) => inSpaces(query.spaceIds) ? resumeWaitingOf(await db(), t.jobs, query, await clock.now()) : {
|
|
848
|
+
resumed: 0,
|
|
849
|
+
functionJobs: []
|
|
736
850
|
}
|
|
737
851
|
};
|
|
738
852
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JobGroup, JobQuery } from '../types';
|
|
2
|
+
import { Pool } from 'mysql2/promise';
|
|
3
|
+
/** The jobs a list names (`listJobs`, `listJobGroups`): the clause and its parameters. */
|
|
4
|
+
export declare const listWhere: ({ spaceIds, name, status, kind }: JobQuery) => {
|
|
5
|
+
sql: string;
|
|
6
|
+
params: unknown[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `JobQueue.listJobGroups` over the jobs table: a group per space, work and status, the one of the most recently
|
|
10
|
+
* touched job first. Each group's latest job — by `updated_at`, then `id`, as `listJobs` orders them — is read off one
|
|
11
|
+
* MAX of the two written as one string: MySQL 5.7 has no window functions. A query naming no space is answered empty
|
|
12
|
+
* by the caller (`IN ()` is not SQL).
|
|
13
|
+
*/
|
|
14
|
+
export declare const listJobGroupsOf: (conn: Pool, table: string, query: JobQuery) => Promise<{
|
|
15
|
+
groups: JobGroup[];
|
|
16
|
+
total: number;
|
|
17
|
+
jobs: number;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JobsResumed, JobsToResume } from '../types';
|
|
2
|
+
import { Pool } from 'mysql2/promise';
|
|
3
|
+
/**
|
|
4
|
+
* A job set aside, back in the queue at the instant of the statement's first two parameters (`resume`,
|
|
5
|
+
* `resumeWaiting`): one set aside after failing every attempt has them all again.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PUT_BACK = "status = 'pending', run_at = ?, updated_at = ?, attempts = IF(attempts >= max_attempts, 0, attempts)";
|
|
8
|
+
/**
|
|
9
|
+
* `JobQueue.resumeWaiting` over the jobs table: every job of these spaces set aside, back in one statement. A query
|
|
10
|
+
* naming no space is answered empty by the caller (`IN ()` is not SQL).
|
|
11
|
+
*/
|
|
12
|
+
export declare const resumeWaitingOf: (conn: Pool, table: string, { spaceIds, kind, name }: JobsToResume, at: number) => Promise<JobsResumed>;
|
package/dist/mysql/rows.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export type JobRow = {
|
|
|
34
34
|
needs_memory_mb: Numeric | null;
|
|
35
35
|
near_memory_limit: Numeric;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* A job's row as a list reads it: every column but what a job of the functions saved (`state`, up to megabytes, and no
|
|
39
|
+
* list shows it) — read as NULL, so `toJob` reads it as none.
|
|
40
|
+
*/
|
|
41
|
+
export declare const LISTED_JOB_COLUMNS: string;
|
|
37
42
|
export type ScheduleRow = {
|
|
38
43
|
space_id: Numeric;
|
|
39
44
|
action_id: string;
|
package/dist/sqlite/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as stateOf, t as documentOf } from "../chunks/queueDocument-
|
|
2
|
-
import { a as emptyState, i as changedBy, o as queueOver, r as applyRule, s as queueRules } from "../chunks/queueRules-
|
|
1
|
+
import { n as stateOf, t as documentOf } from "../chunks/queueDocument-DCBWcxe_.mjs";
|
|
2
|
+
import { a as emptyState, i as changedBy, o as queueOver, r as applyRule, s as queueRules } from "../chunks/queueRules-UGZNkho0.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { DatabaseSync } from "node:sqlite";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { ActionLookupsConfig, ConnectorLookupsConfig, EngineConfig, EngineOptions, EngineServerConfig, SSRActionConfig, ActionJobsConfig } from './config';
|
|
2
|
-
export type { ActionSchedule, ActionScheduleInput, JobClaimMemory, JobQuery, JobQueue, JobFlowMinute, JobQueueSummary, JobSettlement, JobsDropped, JobsNeedingMemory, JobsToDrop, JobSpaces, JobStop, JobTake, JobWake, JobWrite, WaitingJobs } from './jobs';
|
|
2
|
+
export type { ActionSchedule, ActionScheduleInput, JobClaimMemory, JobQuery, JobQueue, JobFlowMinute, JobGroup, JobQueueSummary, JobSettlement, JobsDropped, JobsResumed, JobsNeedingMemory, JobsToDrop, JobsToResume, JobSpaces, JobStop, JobTake, JobWake, JobWrite, WaitingJobs } from './jobs';
|
package/dist/types/jobs.d.ts
CHANGED
|
@@ -146,6 +146,20 @@ export type JobQuery = {
|
|
|
146
146
|
limit: number;
|
|
147
147
|
offset: number;
|
|
148
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Jobs that say the same thing — one space's runs of one work (`target.kind` and `target.name`) in one status: what
|
|
151
|
+
* `JobQueue.listJobGroups` answers as one row, and exactly what `cancelWaiting` drops at once when narrowed to them.
|
|
152
|
+
*/
|
|
153
|
+
export type JobGroup = {
|
|
154
|
+
/** The most recently touched of them, as `listJobs` reads it, without what a job of the functions saved (`state`). */
|
|
155
|
+
latest: Omit<Job, 'state'>;
|
|
156
|
+
/** How many jobs the group holds, `latest` among them. */
|
|
157
|
+
count: number;
|
|
158
|
+
/** The earliest `dueAt` among them. */
|
|
159
|
+
firstDueAt: number;
|
|
160
|
+
/** The latest `dueAt` among them. */
|
|
161
|
+
lastDueAt: number;
|
|
162
|
+
};
|
|
149
163
|
/**
|
|
150
164
|
* Which jobs an operator drops at once (`JobQueue.cancelWaiting`): everything of these spaces that has not started —
|
|
151
165
|
* waiting to run or set aside — narrowed like a list of them is.
|
|
@@ -159,6 +173,17 @@ export type JobsToDrop = {
|
|
|
159
173
|
/** Only what runs this action, or this job (`target.name`). */
|
|
160
174
|
name?: string;
|
|
161
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* Which jobs set aside an operator puts back in the queue at once (`JobQueue.resumeWaiting`): every `paused` job of these
|
|
178
|
+
* spaces, narrowed like a list of them is — what one group of `listJobGroups` holds, when set aside.
|
|
179
|
+
*/
|
|
180
|
+
export type JobsToResume = Omit<JobsToDrop, 'status'>;
|
|
181
|
+
/** What `JobQueue.resumeWaiting` put back. */
|
|
182
|
+
export type JobsResumed = {
|
|
183
|
+
resumed: number;
|
|
184
|
+
/** The jobs of the spaces' functions among them: the ones somebody may be watching, for whoever tells them. */
|
|
185
|
+
functionJobs: string[];
|
|
186
|
+
};
|
|
162
187
|
/** What `JobQueue.cancelWaiting` dropped. */
|
|
163
188
|
export type JobsDropped = {
|
|
164
189
|
cancelled: number;
|
|
@@ -281,6 +306,17 @@ export type JobQueue = {
|
|
|
281
306
|
jobs: Job[];
|
|
282
307
|
total: number;
|
|
283
308
|
}>;
|
|
309
|
+
/**
|
|
310
|
+
* The jobs `listJobs` would list, a {@link JobGroup} per space, work and status — the group of the most recently
|
|
311
|
+
* touched job first — paged by groups, `total` counting them and `jobs` the jobs they hold, every page's. What a queue
|
|
312
|
+
* reads as a list a person scans: a schedule whose every fire was set aside is one row saying how many, not a page of
|
|
313
|
+
* the same line, every page alike.
|
|
314
|
+
*/
|
|
315
|
+
listJobGroups: (query: JobQuery) => Promise<{
|
|
316
|
+
groups: JobGroup[];
|
|
317
|
+
total: number;
|
|
318
|
+
jobs: number;
|
|
319
|
+
}>;
|
|
284
320
|
/**
|
|
285
321
|
* Jobs of EVERY space in these statuses — an operator's view, never a space's own (`listJobs` is): the longest due first
|
|
286
322
|
* (`due`), or the latest written first (`latest`). What a monitoring screen lists of what waits, runs and just ended.
|
|
@@ -354,4 +390,10 @@ export type JobQueue = {
|
|
|
354
390
|
* holding it can stop it.
|
|
355
391
|
*/
|
|
356
392
|
cancelWaiting: (query: JobsToDrop) => Promise<JobsDropped>;
|
|
393
|
+
/**
|
|
394
|
+
* Puts every job of these spaces set aside (`paused`) back in the queue at once, as `resume` puts one — each set aside
|
|
395
|
+
* after failing every attempt with every attempt again. What a group of a schedule's runs set aside asks of an
|
|
396
|
+
* operator once its cause is fixed, rather than a press a job.
|
|
397
|
+
*/
|
|
398
|
+
resumeWaiting: (query: JobsToResume) => Promise<JobsResumed>;
|
|
357
399
|
};
|
package/dist/worker/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { handleRealtimePublish, handleRealtimeSocket, handleRealtimeSubscribe, realtimeModuleFor } from "../realtime/index.mjs";
|
|
2
2
|
import { a as createActionResolver, i as readRenderAsk, n as RENDER_PATH, t as createRemoteRenderResolver } from "../chunks/remote-DZSzOO01.mjs";
|
|
3
|
-
import { F as readKeptCall, P as keepCall, R as writeConnectorRecord, S as ACTIONS_FLEET_STORES, h as precheckRun, t as createActionsModule } from "../chunks/module-
|
|
3
|
+
import { F as readKeptCall, P as keepCall, R as writeConnectorRecord, S as ACTIONS_FLEET_STORES, h as precheckRun, t as createActionsModule } from "../chunks/module-Baod2T6h.mjs";
|
|
4
4
|
import { a as triggerParams, i as findTriggerNode, t as ActionRunError } from "../chunks/errors-bCBfIe7c.mjs";
|
|
5
|
-
import { r as createConnectorResolver, t as describeCatalog } from "../chunks/taskCatalog-
|
|
6
|
-
import { t as isFunctionsDefinition } from "../chunks/load-
|
|
5
|
+
import { r as createConnectorResolver, t as describeCatalog } from "../chunks/taskCatalog-J9hBMCsz.mjs";
|
|
6
|
+
import { t as isFunctionsDefinition } from "../chunks/load-tw8iAgZy.mjs";
|
|
7
7
|
import { privateOriginsOf } from "@plitzi/sdk-kernel/outbound";
|
|
8
8
|
import { isConnectorManifestDraft, validateConnectorManifest } from "@plitzi/sdk-shared/connectors";
|
|
9
9
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
@@ -13,7 +13,7 @@ import { configureServerLog, defaultLogLevel, serverLog } from "@plitzi/sdk-kern
|
|
|
13
13
|
import { statsRecorderFor, statsStage } from "@plitzi/sdk-kernel/stats";
|
|
14
14
|
import { protocolRefusal } from "@plitzi/sdk-shared/functions";
|
|
15
15
|
import { bearerMatches, clientIp, createHttpServer, createMiddlewaresStage, crossSiteWritesStage, healthStage, makeHandler, onAbort, openEventStream, readRawBody, readRawBytes, requestAuthority, requestOrigin, runsFleetJobs, writeWebResponse } from "@plitzi/sdk-kernel/http";
|
|
16
|
-
import { forcedFlagsFor } from "@plitzi/sdk-shared/flags";
|
|
16
|
+
import { forcedFlagsFor, keptRollout } from "@plitzi/sdk-shared/flags";
|
|
17
17
|
import { resolveDebugAuthorization } from "@plitzi/sdk-kernel/identity";
|
|
18
18
|
import { request } from "node:http";
|
|
19
19
|
// src/engine/transport/stream.ts
|
|
@@ -328,6 +328,7 @@ var handleActionCall = async (deps) => {
|
|
|
328
328
|
revision
|
|
329
329
|
},
|
|
330
330
|
...forcedFlags ? { forcedFlags } : {},
|
|
331
|
+
rolloutBuckets: keptRollout(req.headers.cookie, requestAuthority(req)),
|
|
331
332
|
signal: run.controller.signal,
|
|
332
333
|
...stream ? {
|
|
333
334
|
emit: (chunk) => stream.send({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-actions",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"description": "The actions engine: server actions, a space's functions and runtimes as the platform holds them, the connectors, realtime, jobs, and the stock queues and stores. What a worker runs; what a page server is handed.",
|
|
6
6
|
"files": [
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"build:prod": "vite build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
41
|
-
"@plitzi/sdk-shared": "0.39.
|
|
40
|
+
"@plitzi/sdk-kernel": "0.39.12",
|
|
41
|
+
"@plitzi/sdk-shared": "0.39.12",
|
|
42
42
|
"nodemailer": "^10.6.0",
|
|
43
43
|
"ws": "^8.23.0"
|
|
44
44
|
},
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@plitzi/sdk-runtime": "0.39.
|
|
62
|
+
"@plitzi/sdk-runtime": "0.39.12",
|
|
63
63
|
"@types/node": "^26.6.6",
|
|
64
64
|
"@types/nodemailer": "^8.0.2",
|
|
65
65
|
"@types/ws": "^8.18.2",
|