@elaraai/e3-web 1.0.103 → 1.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/app.d.ts +4 -2
- package/dist/src/app.d.ts.map +1 -1
- package/dist/src/app.js +9 -5
- package/dist/src/app.js.map +1 -1
- package/dist/src/browser/e3-api.js +1 -1
- package/dist/src/browser/e3-api.js.map +1 -1
- package/dist/src/storage/WebFunctionCallStore.d.ts +59 -0
- package/dist/src/storage/WebFunctionCallStore.d.ts.map +1 -0
- package/dist/src/storage/WebFunctionCallStore.js +218 -0
- package/dist/src/storage/WebFunctionCallStore.js.map +1 -0
- package/dist/src/storage/WebStorage.d.ts +3 -0
- package/dist/src/storage/WebStorage.d.ts.map +1 -1
- package/dist/src/storage/WebStorage.js +24 -9
- package/dist/src/storage/WebStorage.js.map +1 -1
- package/dist/src/storage/record-keys.d.ts +4 -0
- package/dist/src/storage/record-keys.d.ts.map +1 -1
- package/dist/src/storage/record-keys.js +4 -0
- package/dist/src/storage/record-keys.js.map +1 -1
- package/dist/src/storage/stores.spec.js +5 -4
- package/dist/src/storage/stores.spec.js.map +1 -1
- package/dist/src/testing/runner-cases.d.ts.map +1 -1
- package/dist/src/testing/runner-cases.js +2 -1
- package/dist/src/testing/runner-cases.js.map +1 -1
- package/dist/src/transfer/WebTransferBackend.d.ts +39 -5
- package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -1
- package/dist/src/transfer/WebTransferBackend.js +49 -7
- package/dist/src/transfer/WebTransferBackend.js.map +1 -1
- package/dist/src/worker.js +2 -0
- package/dist/src/worker.js.map +1 -1
- package/dist/src/worker.spec.js +31 -2
- package/dist/src/worker.spec.js.map +1 -1
- package/package.json +9 -9
package/dist/src/app.d.ts
CHANGED
|
@@ -80,8 +80,10 @@ export type WebApp = Hono<{
|
|
|
80
80
|
* upgrades it owes in the request, as an in-page request has no time
|
|
81
81
|
* limit; and the repositories' own routes;
|
|
82
82
|
* - a repository's status, gc, packages and their transfer, workspaces,
|
|
83
|
-
* datasets and their transfer, tasks, functions
|
|
84
|
-
*
|
|
83
|
+
* datasets and their transfer, tasks, functions — each call through a
|
|
84
|
+
* workspace run in this worker and kept for its lifetime, polled, cancelled
|
|
85
|
+
* and listed at `…/calls` — and one-shot with its split calls under the
|
|
86
|
+
* host's `access`, records, the dataflow, and objects.
|
|
85
87
|
*
|
|
86
88
|
* @param seams - The storage, transfers, runners, orchestrator and state
|
|
87
89
|
* store the routes run over, and who may run what
|
package/dist/src/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAa,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5H,OAAO,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAa,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5H,OAAO,EAkBL,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE3E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEhH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAC;IACjD,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C;8BAC0B;IAC1B,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B;;kDAE8C;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B;8EAC0E;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC;AAalE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CA2EvD"}
|
package/dist/src/app.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { Hono } from 'hono';
|
|
14
14
|
import { checkName } from '@elaraai/e3-core/portable';
|
|
15
|
-
import { createDatasetRoutes, createExecutionRoutes, createObjectRoutes, createOneShotRoutes, createPackageFunctionRoutes, createPackageRoutes, createPackageTransferRoutes, createRepositoriesRoutes, createRepositoryGate, createRepositoryRoutes, createTaskRoutes, createTransferRoutes, createWorkspaceFunctionRoutes, createWorkspaceBundleRoutes, createWorkspaceRecordRoutes, createWorkspaceRoutes, } from '@elaraai/e3-api-server/portable';
|
|
15
|
+
import { createDatasetRoutes, createExecutionRoutes, createObjectRoutes, createOneShotRoutes, createPackageFunctionRoutes, createPackageRoutes, createPackageTransferRoutes, createRepositoriesRoutes, createRepositoryGate, createRepositoryRoutes, createTaskRoutes, createTransferRoutes, createWorkspaceCallRoutes, createWorkspaceFunctionRoutes, createWorkspaceBundleRoutes, createWorkspaceRecordRoutes, createWorkspaceRoutes, } from '@elaraai/e3-api-server/portable';
|
|
16
16
|
import { createWebDataEndpoints } from './transfer/endpoints.js';
|
|
17
17
|
/**
|
|
18
18
|
* The repository a request names, as WebStorage's stores take it: its name,
|
|
@@ -39,8 +39,10 @@ function repositoryOf(repo) {
|
|
|
39
39
|
* upgrades it owes in the request, as an in-page request has no time
|
|
40
40
|
* limit; and the repositories' own routes;
|
|
41
41
|
* - a repository's status, gc, packages and their transfer, workspaces,
|
|
42
|
-
* datasets and their transfer, tasks, functions
|
|
43
|
-
*
|
|
42
|
+
* datasets and their transfer, tasks, functions — each call through a
|
|
43
|
+
* workspace run in this worker and kept for its lifetime, polled, cancelled
|
|
44
|
+
* and listed at `…/calls` — and one-shot with its split calls under the
|
|
45
|
+
* host's `access`, records, the dataflow, and objects.
|
|
44
46
|
*
|
|
45
47
|
* @param seams - The storage, transfers, runners, orchestrator and state
|
|
46
48
|
* store the routes run over, and who may run what
|
|
@@ -93,9 +95,11 @@ export function createWebApp(seams) {
|
|
|
93
95
|
});
|
|
94
96
|
app.route('/api/repos/:repo/workspaces/:ws/datasets', datasetTransfer.api);
|
|
95
97
|
app.route('/api/repos/:repo/workspaces/:ws/datasets', createDatasetRoutes(storage, repositoryOf, transfer));
|
|
96
|
-
// Tasks, functions, one-shot and its split calls, and
|
|
98
|
+
// Tasks, functions and their kept calls, one-shot and its split calls, and
|
|
99
|
+
// records.
|
|
97
100
|
app.route('/api/repos/:repo/workspaces/:ws/tasks', createTaskRoutes(storage, repositoryOf));
|
|
98
|
-
app.route('/api/repos/:repo/workspaces/:ws/functions', createWorkspaceFunctionRoutes(storage, repositoryOf,
|
|
101
|
+
app.route('/api/repos/:repo/workspaces/:ws/functions', createWorkspaceFunctionRoutes(storage, repositoryOf, transfer, { access }));
|
|
102
|
+
app.route('/api/repos/:repo/workspaces/:ws/calls', createWorkspaceCallRoutes(storage, repositoryOf, transfer));
|
|
99
103
|
app.route('/api/repos/:repo/workspaces/:ws/one-shot', createOneShotRoutes(storage, repositoryOf, transfer, getRunner, { access }));
|
|
100
104
|
app.route('/api/repos/:repo/workspaces/:ws/records', createWorkspaceRecordRoutes(storage, repositoryOf, getRunner));
|
|
101
105
|
// The dataflow: run, polled and cancelled through the orchestrator, whose
|
package/dist/src/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAwE,MAAM,2BAA2B,CAAC;AAC5H,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,GAGtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAoDjE;;;;;GAKG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.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OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACnI,GAAG,CAAC,KAAK,CAAC,uCAAuC,EAAE,yBAAyB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/G,GAAG,CAAC,KAAK,CAAC,0CAA0C,EAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACnI,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,2BAA2B,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpH,0EAA0E;IAC1E,sCAAsC;IACtC,GAAG,CAAC,KAAK,CAAC,0CAA0C,EAAE,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE;QACjG,SAAS;QACT,eAAe,EAAE,GAAG,EAAE,CAAC,YAAY;QACnC,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,KAAK;KACN,CAAC,CAAC,CAAC;IAEJ,4DAA4D;IAC5D,GAAG,CAAC,KAAK,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE3F,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -33,7 +33,7 @@ import { Harness } from './harness.js';
|
|
|
33
33
|
*/
|
|
34
34
|
export const API_SUITE_PARTS = [
|
|
35
35
|
['repository', 'packages', 'workspaces', 'datasets', 'datasetPages', 'datasetBatches', 'datasetTransfer', 'packageTransfer', 'platform'],
|
|
36
|
-
['dataflow'],
|
|
36
|
+
['dataflow', 'calls'],
|
|
37
37
|
['functions', 'records', 'keyedRecords', 'areaRecords', 'placeRecords', 'seriesRecords', 'recordDeploy', 'inputDeploy'],
|
|
38
38
|
];
|
|
39
39
|
/** The pages and workers a part's harness serves. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e3-api.js","sourceRoot":"","sources":["../../../src/browser/e3-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAoC,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAqC;IAC/D,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,CAAC;IACxI,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"e3-api.js","sourceRoot":"","sources":["../../../src/browser/e3-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAoC,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAA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AAC;gBACD,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAC;YACH,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7B,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QAEF,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YACtC,IAAI,QAAQ,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,GAAG,CAAC,CAAC;YACxF,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QAED,0EAA0E;QAC1E,wEAAwE;QACxE,4DAA4D;QAC5D,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAChE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE,kCAAkC,CAAC,CAAC;YAClE,MAAM,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,EAAE,0CAA0C,CAAC,CAAC;YACpE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,yBAAyB,CAAC,CAAC;QACpG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { type FunctionCallCancel, type FunctionCallJob } from '@elaraai/e3-types';
|
|
6
|
+
import { type FunctionCallEnd, type FunctionCallListOptions, type FunctionCallListPage, type FunctionCallStore } from '@elaraai/e3-core/portable';
|
|
7
|
+
import type { RecordsAdapter } from './adapters.js';
|
|
8
|
+
/**
|
|
9
|
+
* The calls of a `WebStorage`'s repositories, each a record at
|
|
10
|
+
* `['repo', <repo>, 'call', <workspace>, <id>]`.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* A call's id is a UUIDv7, so its workspace's keys scan in the order its calls
|
|
14
|
+
* started, and a list reads them from the latest. Each write of a call is a
|
|
15
|
+
* transaction that reads it, so its end and a request to cancel it land one
|
|
16
|
+
* after the other, whichever tab makes them: the first end stands. A call past
|
|
17
|
+
* its `expiresAt` is gone for every read, which deletes it as it passes, and
|
|
18
|
+
* gc's sweep deletes every one ({@link sweepExpired}). A workspace's removal
|
|
19
|
+
* takes its calls in its own transaction, and a repository's removal every
|
|
20
|
+
* call it keeps.
|
|
21
|
+
*/
|
|
22
|
+
export declare class WebFunctionCallStore implements FunctionCallStore {
|
|
23
|
+
private readonly records;
|
|
24
|
+
private readonly now;
|
|
25
|
+
/**
|
|
26
|
+
* @param records - The records the calls are kept in
|
|
27
|
+
* @param now - Reads the time, in epoch milliseconds, which a call's expiry
|
|
28
|
+
* is measured by (default `Date.now`)
|
|
29
|
+
*/
|
|
30
|
+
constructor(records: RecordsAdapter, now?: () => number);
|
|
31
|
+
create(repo: string, job: FunctionCallJob): Promise<void>;
|
|
32
|
+
get(repo: string, workspace: string, id: string): Promise<FunctionCallJob | null>;
|
|
33
|
+
end(repo: string, workspace: string, id: string, end: FunctionCallEnd): Promise<FunctionCallJob | null>;
|
|
34
|
+
requestCancel(repo: string, workspace: string, id: string, cancel: FunctionCallCancel): Promise<FunctionCallJob | null>;
|
|
35
|
+
/** Reads the workspace's calls from the latest, a page of records at a
|
|
36
|
+
* time, until it has the page it was asked for or none are left. */
|
|
37
|
+
list(repo: string, workspace: string, options: FunctionCallListOptions): Promise<FunctionCallListPage>;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes every expired call of a repository: what gc's sweep does, beside
|
|
40
|
+
* the reads that delete one as they pass it.
|
|
41
|
+
*
|
|
42
|
+
* @param repo - Repository identifier
|
|
43
|
+
* @param dryRun - Count them, and delete none
|
|
44
|
+
* @returns How many expired calls there were
|
|
45
|
+
*/
|
|
46
|
+
sweepExpired(repo: string, dryRun: boolean): Promise<number>;
|
|
47
|
+
/** The prefix of a workspace's calls' keys, its name checked. */
|
|
48
|
+
private prefix;
|
|
49
|
+
/** A call's key, its workspace's name and its id checked. */
|
|
50
|
+
private key;
|
|
51
|
+
/** The call a key holds in a transaction, or `null` when there is none, or
|
|
52
|
+
* it has expired, which the transaction deletes. */
|
|
53
|
+
private live;
|
|
54
|
+
/** Deletes the calls at the keys that are still expired: one written again
|
|
55
|
+
* meanwhile is left. */
|
|
56
|
+
private forget;
|
|
57
|
+
private expired;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=WebFunctionCallStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebFunctionCallStore.d.ts","sourceRoot":"","sources":["../../../src/storage/WebFunctionCallStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAgD,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChI,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAa,cAAc,EAAsB,MAAM,eAAe,CAAC;AAmBnF;;;;;;;;;;;;;GAaG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAMhD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAkB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAL1E;;;;OAIG;IACH,YAA6B,OAAO,EAAE,cAAc,EAAmB,GAAG,GAAE,MAAM,MAAiB,EAAI;IAEjG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9D;IAEK,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAQtF;IAEK,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAqB5G;IAEK,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAS5H;IAED;yEACqE;IAC/D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiC3G;IAED;;;;;;;OAOG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAejE;IAED,iEAAiE;IACjE,OAAO,CAAC,MAAM;IAKd,6DAA6D;IAC7D,OAAO,CAAC,GAAG;IAMX;yDACqD;YACvC,IAAI;IASlB;6BACyB;YACX,MAAM;IAUpB,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The calls a `WebStorage` keeps (east-workspace#1554): each call of a named
|
|
7
|
+
* function through a workspace, and each one-shot started as a call, a record
|
|
8
|
+
* of the records adapter, from its start to the end of the lifetime its end
|
|
9
|
+
* gives it.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { some } from '@elaraai/east';
|
|
14
|
+
import { decodeFunctionCallJob, encodeFunctionCallJob } from '@elaraai/e3-types';
|
|
15
|
+
import { checkId, checkName, checkPageLimit, } from '@elaraai/e3-core/portable';
|
|
16
|
+
import { recordKeys } from './record-keys.js';
|
|
17
|
+
/** How many of a workspace's calls a list reads at a time, as it passes over
|
|
18
|
+
* those it leaves out. */
|
|
19
|
+
const LIST_PAGE = 100;
|
|
20
|
+
/** How many of a repository's calls a sweep reads at a time. */
|
|
21
|
+
const SWEEP_PAGE = 500;
|
|
22
|
+
/** A record's call, or `null` when it does not decode: an earlier release's. */
|
|
23
|
+
function decoded(data) {
|
|
24
|
+
try {
|
|
25
|
+
return decodeFunctionCallJob(data);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The calls of a `WebStorage`'s repositories, each a record at
|
|
33
|
+
* `['repo', <repo>, 'call', <workspace>, <id>]`.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* A call's id is a UUIDv7, so its workspace's keys scan in the order its calls
|
|
37
|
+
* started, and a list reads them from the latest. Each write of a call is a
|
|
38
|
+
* transaction that reads it, so its end and a request to cancel it land one
|
|
39
|
+
* after the other, whichever tab makes them: the first end stands. A call past
|
|
40
|
+
* its `expiresAt` is gone for every read, which deletes it as it passes, and
|
|
41
|
+
* gc's sweep deletes every one ({@link sweepExpired}). A workspace's removal
|
|
42
|
+
* takes its calls in its own transaction, and a repository's removal every
|
|
43
|
+
* call it keeps.
|
|
44
|
+
*/
|
|
45
|
+
export class WebFunctionCallStore {
|
|
46
|
+
records;
|
|
47
|
+
now;
|
|
48
|
+
/**
|
|
49
|
+
* @param records - The records the calls are kept in
|
|
50
|
+
* @param now - Reads the time, in epoch milliseconds, which a call's expiry
|
|
51
|
+
* is measured by (default `Date.now`)
|
|
52
|
+
*/
|
|
53
|
+
constructor(records, now = Date.now) {
|
|
54
|
+
this.records = records;
|
|
55
|
+
this.now = now;
|
|
56
|
+
}
|
|
57
|
+
async create(repo, job) {
|
|
58
|
+
const key = this.key(repo, job.workspace, job.call.id);
|
|
59
|
+
await this.records.transact(async (tx) => {
|
|
60
|
+
if (await this.live(tx, key) !== null)
|
|
61
|
+
throw new Error(`workspace '${job.workspace}' keeps a call ${job.call.id} already`);
|
|
62
|
+
tx.put(key, encodeFunctionCallJob(job));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async get(repo, workspace, id) {
|
|
66
|
+
const key = this.key(repo, workspace, id);
|
|
67
|
+
const data = await this.records.get(key);
|
|
68
|
+
if (data === null)
|
|
69
|
+
return null;
|
|
70
|
+
const job = decodeFunctionCallJob(data);
|
|
71
|
+
if (!this.expired(job))
|
|
72
|
+
return job;
|
|
73
|
+
await this.forget([key]);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
async end(repo, workspace, id, end) {
|
|
77
|
+
const key = this.key(repo, workspace, id);
|
|
78
|
+
return this.records.transact(async (tx) => {
|
|
79
|
+
const job = await this.live(tx, key);
|
|
80
|
+
if (job === null || job.call.state.type !== 'running')
|
|
81
|
+
return job;
|
|
82
|
+
const ended = {
|
|
83
|
+
...job,
|
|
84
|
+
call: {
|
|
85
|
+
...job.call,
|
|
86
|
+
state: end.state,
|
|
87
|
+
endedAt: some(end.endedAt),
|
|
88
|
+
expiresAt: end.expiresAt,
|
|
89
|
+
stdout: end.stdout,
|
|
90
|
+
stderr: end.stderr,
|
|
91
|
+
stdoutTruncated: end.stdoutTruncated,
|
|
92
|
+
stderrTruncated: end.stderrTruncated,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
tx.put(key, encodeFunctionCallJob(ended));
|
|
96
|
+
return ended;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async requestCancel(repo, workspace, id, cancel) {
|
|
100
|
+
const key = this.key(repo, workspace, id);
|
|
101
|
+
return this.records.transact(async (tx) => {
|
|
102
|
+
const job = await this.live(tx, key);
|
|
103
|
+
if (job === null || job.call.state.type !== 'running' || job.cancel.type === 'some')
|
|
104
|
+
return job;
|
|
105
|
+
const asked = { ...job, cancel: some(cancel) };
|
|
106
|
+
tx.put(key, encodeFunctionCallJob(asked));
|
|
107
|
+
return asked;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Reads the workspace's calls from the latest, a page of records at a
|
|
111
|
+
* time, until it has the page it was asked for or none are left. */
|
|
112
|
+
async list(repo, workspace, options) {
|
|
113
|
+
checkPageLimit(options.limit);
|
|
114
|
+
if (options.before !== undefined)
|
|
115
|
+
checkId('call id', options.before);
|
|
116
|
+
const prefix = this.prefix(repo, workspace);
|
|
117
|
+
const calls = [];
|
|
118
|
+
const expired = [];
|
|
119
|
+
let next;
|
|
120
|
+
let before = options.before === undefined ? undefined : [...prefix, options.before];
|
|
121
|
+
scanning: for (;;) {
|
|
122
|
+
const entries = await this.records.scan(prefix, { reverse: true, limit: LIST_PAGE, ...(before !== undefined && { before }) });
|
|
123
|
+
for (const [at, { key, value }] of entries.entries()) {
|
|
124
|
+
// A record that does not decode keeps no call a reader can be shown
|
|
125
|
+
const job = decoded(value);
|
|
126
|
+
if (job === null)
|
|
127
|
+
continue;
|
|
128
|
+
if (this.expired(job)) {
|
|
129
|
+
expired.push(key);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
// A function's calls: a one-shot names none
|
|
133
|
+
if (options.function !== undefined && !(job.call.function.type === 'some' && job.call.function.value === options.function))
|
|
134
|
+
continue;
|
|
135
|
+
if (options.state !== undefined && job.call.state.type !== options.state)
|
|
136
|
+
continue;
|
|
137
|
+
calls.push(job);
|
|
138
|
+
if (calls.length >= options.limit) {
|
|
139
|
+
// A full page names the next while records are left before its last
|
|
140
|
+
if (at < entries.length - 1 || entries.length === LIST_PAGE)
|
|
141
|
+
next = job.call.id;
|
|
142
|
+
break scanning;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (entries.length < LIST_PAGE)
|
|
146
|
+
break;
|
|
147
|
+
before = entries[entries.length - 1].key;
|
|
148
|
+
}
|
|
149
|
+
if (expired.length > 0)
|
|
150
|
+
await this.forget(expired);
|
|
151
|
+
return next === undefined ? { calls } : { calls, next };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Deletes every expired call of a repository: what gc's sweep does, beside
|
|
155
|
+
* the reads that delete one as they pass it.
|
|
156
|
+
*
|
|
157
|
+
* @param repo - Repository identifier
|
|
158
|
+
* @param dryRun - Count them, and delete none
|
|
159
|
+
* @returns How many expired calls there were
|
|
160
|
+
*/
|
|
161
|
+
async sweepExpired(repo, dryRun) {
|
|
162
|
+
const prefix = recordKeys.kind(repo, 'call');
|
|
163
|
+
let count = 0;
|
|
164
|
+
let after;
|
|
165
|
+
for (;;) {
|
|
166
|
+
const entries = await this.records.scan(prefix, { limit: SWEEP_PAGE, ...(after !== undefined && { after }) });
|
|
167
|
+
const expired = entries.filter(({ value }) => {
|
|
168
|
+
const job = decoded(value);
|
|
169
|
+
return job !== null && this.expired(job);
|
|
170
|
+
}).map(({ key }) => key);
|
|
171
|
+
count += expired.length;
|
|
172
|
+
if (!dryRun && expired.length > 0)
|
|
173
|
+
await this.forget(expired);
|
|
174
|
+
if (entries.length < SWEEP_PAGE)
|
|
175
|
+
return count;
|
|
176
|
+
after = entries[entries.length - 1].key;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** The prefix of a workspace's calls' keys, its name checked. */
|
|
180
|
+
prefix(repo, workspace) {
|
|
181
|
+
checkName('workspace', workspace);
|
|
182
|
+
return [...recordKeys.kind(repo, 'call'), workspace];
|
|
183
|
+
}
|
|
184
|
+
/** A call's key, its workspace's name and its id checked. */
|
|
185
|
+
key(repo, workspace, id) {
|
|
186
|
+
checkName('workspace', workspace);
|
|
187
|
+
checkId('call id', id);
|
|
188
|
+
return recordKeys.call(repo, workspace, id);
|
|
189
|
+
}
|
|
190
|
+
/** The call a key holds in a transaction, or `null` when there is none, or
|
|
191
|
+
* it has expired, which the transaction deletes. */
|
|
192
|
+
async live(tx, key) {
|
|
193
|
+
const data = await tx.get(key);
|
|
194
|
+
if (data === null)
|
|
195
|
+
return null;
|
|
196
|
+
const job = decodeFunctionCallJob(data);
|
|
197
|
+
if (!this.expired(job))
|
|
198
|
+
return job;
|
|
199
|
+
tx.delete(key);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
/** Deletes the calls at the keys that are still expired: one written again
|
|
203
|
+
* meanwhile is left. */
|
|
204
|
+
async forget(keys) {
|
|
205
|
+
await this.records.transact(async (tx) => {
|
|
206
|
+
for (const key of keys) {
|
|
207
|
+
const data = await tx.get(key);
|
|
208
|
+
const job = data === null ? null : decoded(data);
|
|
209
|
+
if (job !== null && this.expired(job))
|
|
210
|
+
tx.delete(key);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
expired(job) {
|
|
215
|
+
return job.call.expiresAt.getTime() <= this.now();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=WebFunctionCallStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebFunctionCallStore.js","sourceRoot":"","sources":["../../../src/storage/WebFunctionCallStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAiD,MAAM,mBAAmB,CAAC;AAChI,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,GAKf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;2BAC2B;AAC3B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,gEAAgE;AAChE,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,gFAAgF;AAChF,SAAS,OAAO,CAAC,IAAgB;IAC/B,IAA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AE,EAAE,EAAE,EAAE;YACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACjD,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;oBAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,OAAO,CAAC,GAAoB;QAClC,OAAO,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { type DatasetRefStore, type ExecutionStateStore, type LockService, type LogStore, type ObjectStore, type RefStore, type RepoStore, type RepositoryUpgrade, type StorageBackend } from '@elaraai/e3-core/portable';
|
|
6
6
|
import type { BlobKey, BlobsAdapter, FilesAdapter, LocksAdapter, RecordKey, RecordsAdapter } from './adapters.js';
|
|
7
7
|
import { recordKeys } from './record-keys.js';
|
|
8
|
+
import { WebFunctionCallStore } from './WebFunctionCallStore.js';
|
|
8
9
|
export { recordKeys };
|
|
9
10
|
/** The kinds of record a transfer backend over a `WebStorage` keeps. */
|
|
10
11
|
export type TransferKind = 'upload' | 'download' | 'import' | 'export' | 'deploy' | 'gc' | 'split';
|
|
@@ -154,6 +155,8 @@ export declare class WebStorage implements StorageBackend {
|
|
|
154
155
|
readonly logs: LogStore;
|
|
155
156
|
readonly repos: RepoStore;
|
|
156
157
|
readonly datasets: DatasetRefStore;
|
|
158
|
+
/** The calls of named functions each repository keeps, in the same records */
|
|
159
|
+
readonly calls: WebFunctionCallStore;
|
|
157
160
|
/** Every repository's runs' states, in the same records */
|
|
158
161
|
private readonly states;
|
|
159
162
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebStorage.d.ts","sourceRoot":"","sources":["../../../src/storage/WebStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuDH,OAAO,
|
|
1
|
+
{"version":3,"file":"WebStorage.d.ts","sourceRoot":"","sources":["../../../src/storage/WebStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuDH,OAAO,EAqBL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAQxB,KAAK,WAAW,EAGhB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EAGb,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAmC,MAAM,eAAe,CAAC;AAInJ,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUjE,OAAO,EAAE,UAAU,EAAE,CAAC;AAWtB,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;AAEnG;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;IACvB,8BAA8B;IAC9B,GAAG,QAAM,SAAS;IAClB,6BAA6B;IAC7B,IAAI,SAAS,YAAY,KAAG,SAAS;IACrC,yBAAyB;IACzB,EAAE,SAAS,YAAY,MAAM,MAAM,KAAG,SAAS;CAChD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB,uDAAuD;IACvD,GAAG,SAAS,MAAM,KAAG,OAAO;IAC5B,mCAAmC;IACnC,EA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raai/east';
|
|
22
22
|
import { DataflowRunType, DatasetRefType, ExecutionOwnerType, ExecutionStatusType, LockHolderVariantType, LockProgressType, LockStateType, RepoMetadataType, RepositoryRecordType, RepositoryUpgradeProgressType, decodeExecutionStatus, } from '@elaraai/e3-types';
|
|
23
|
-
import { DatasetRefConflictError, ExecutionCorruptError, ObjectNotFoundError, RepoAlreadyExistsError, RepoNotFoundError, RepoStatusConflictError, checkHash, checkId, checkName, checkPageLimit, completeUtf8Length, computeHash, executionRoots, isObjectHash, isUuidv7, newRepositoryRecord, packageRoots, workspaceRoots, } from '@elaraai/e3-core/portable';
|
|
23
|
+
import { DatasetRefConflictError, ExecutionCorruptError, ObjectNotFoundError, RepoAlreadyExistsError, RepoNotFoundError, RepoStatusConflictError, checkHash, checkId, checkName, callRoots, checkPageLimit, completeUtf8Length, computeHash, executionRoots, isObjectHash, isUuidv7, newRepositoryRecord, packageRoots, workspaceRoots, } from '@elaraai/e3-core/portable';
|
|
24
24
|
import { openIndexedDbRecords } from './indexeddb.js';
|
|
25
25
|
import { MemoryBlobs, MemoryFiles, MemoryLockSpace, openMemoryRecords } from './memory.js';
|
|
26
26
|
import { OpfsBlobs, OpfsFiles, opfsDirectory } from './opfs.js';
|
|
27
27
|
import { recordKeys } from './record-keys.js';
|
|
28
|
+
import { WebFunctionCallStore } from './WebFunctionCallStore.js';
|
|
28
29
|
import { WebStateStore } from './WebStateStore.js';
|
|
29
30
|
import { openWebLocks } from './web-locks.js';
|
|
30
31
|
// =============================================================================
|
|
@@ -503,10 +504,11 @@ class WebRefStore {
|
|
|
503
504
|
}
|
|
504
505
|
/**
|
|
505
506
|
* Removes a workspace's record, and with it everything kept under its name:
|
|
506
|
-
* its dataset refs, its runs' records, its runs' states and events,
|
|
507
|
-
* revision token, in one transaction, so nothing is left
|
|
508
|
-
* locks are the lock service's, which takes the state a
|
|
509
|
-
* no one's, and writes over it when the lock is next
|
|
507
|
+
* its dataset refs, its runs' records, its runs' states and events, its
|
|
508
|
+
* kept calls, and its revision token, in one transaction, so nothing is left
|
|
509
|
+
* for the sweep. Its locks are the lock service's, which takes the state a
|
|
510
|
+
* closed tab left for no one's, and writes over it when the lock is next
|
|
511
|
+
* held.
|
|
510
512
|
*/
|
|
511
513
|
async workspaceRemove(repo, name) {
|
|
512
514
|
checkName('workspace', name);
|
|
@@ -517,6 +519,7 @@ class WebRefStore {
|
|
|
517
519
|
tx.deletePrefix([...recordKeys.kind(repo, 'run'), name]);
|
|
518
520
|
tx.deletePrefix([...recordKeys.kind(repo, 'state'), name]);
|
|
519
521
|
tx.deletePrefix([...recordKeys.kind(repo, 'event'), name]);
|
|
522
|
+
tx.deletePrefix([...recordKeys.kind(repo, 'call'), name]);
|
|
520
523
|
});
|
|
521
524
|
}
|
|
522
525
|
/** A removal takes everything under the name in its transaction: there is
|
|
@@ -1102,12 +1105,14 @@ class WebRepoStore {
|
|
|
1102
1105
|
blobs;
|
|
1103
1106
|
refs;
|
|
1104
1107
|
datasets;
|
|
1108
|
+
calls;
|
|
1105
1109
|
upgrades;
|
|
1106
|
-
constructor(records, blobs, refs, datasets, upgrades) {
|
|
1110
|
+
constructor(records, blobs, refs, datasets, calls, upgrades) {
|
|
1107
1111
|
this.records = records;
|
|
1108
1112
|
this.blobs = blobs;
|
|
1109
1113
|
this.refs = refs;
|
|
1110
1114
|
this.datasets = datasets;
|
|
1115
|
+
this.calls = calls;
|
|
1111
1116
|
this.upgrades = upgrades;
|
|
1112
1117
|
}
|
|
1113
1118
|
async list() {
|
|
@@ -1182,6 +1187,9 @@ class WebRepoStore {
|
|
|
1182
1187
|
async gcScanExecutionRoots(repo, _cursor) {
|
|
1183
1188
|
return { roots: await executionRoots(this.refs, repo) };
|
|
1184
1189
|
}
|
|
1190
|
+
async gcScanCallRoots(repo, _cursor) {
|
|
1191
|
+
return { roots: await callRoots(this.refs, this.calls, repo) };
|
|
1192
|
+
}
|
|
1185
1193
|
/** A page of the catalogue, a thousand objects at a time; the cursor is the
|
|
1186
1194
|
* last page's last hash. */
|
|
1187
1195
|
async gcScanObjects(repo, cursor) {
|
|
@@ -1299,9 +1307,10 @@ class WebRepoStore {
|
|
|
1299
1307
|
* store staged (a tab closed mid-write), a write in flight recorded longer
|
|
1300
1308
|
* ago than the age gate, with its blob, and the blobs nothing names — a
|
|
1301
1309
|
* delete cut short between an entry and its blob, or a write's blob that
|
|
1302
|
-
* another write of the same bytes beat to the catalogue —
|
|
1310
|
+
* another write of the same bytes beat to the catalogue — what transfers
|
|
1303
1311
|
* staged ({@link stagedKeys}) that no transfer's record names, past the age
|
|
1304
|
-
* gate, or that is older than {@link TRANSFER_RETENTION_MS}
|
|
1312
|
+
* gate, or that is older than {@link TRANSFER_RETENTION_MS}, and the kept
|
|
1313
|
+
* calls whose lifetimes have ended.
|
|
1305
1314
|
*
|
|
1306
1315
|
* @remarks
|
|
1307
1316
|
* A write in flight younger than the age gate is left; one older is taken
|
|
@@ -1382,6 +1391,9 @@ class WebRepoStore {
|
|
|
1382
1391
|
deletedPartials += count;
|
|
1383
1392
|
}
|
|
1384
1393
|
}
|
|
1394
|
+
// The calls whose lifetimes have ended, which every read already leaves
|
|
1395
|
+
// out: no objects, so they count as nothing gc frees
|
|
1396
|
+
await this.calls.sweepExpired(repo, dryRun);
|
|
1385
1397
|
return { deletedPartials, skippedYoung };
|
|
1386
1398
|
}
|
|
1387
1399
|
}
|
|
@@ -1420,6 +1432,8 @@ export class WebStorage {
|
|
|
1420
1432
|
logs;
|
|
1421
1433
|
repos;
|
|
1422
1434
|
datasets;
|
|
1435
|
+
/** The calls of named functions each repository keeps, in the same records */
|
|
1436
|
+
calls;
|
|
1423
1437
|
/** Every repository's runs' states, in the same records */
|
|
1424
1438
|
states;
|
|
1425
1439
|
/**
|
|
@@ -1433,7 +1447,8 @@ export class WebStorage {
|
|
|
1433
1447
|
this.locks = new WebLockService(records, locks);
|
|
1434
1448
|
this.logs = new WebLogStore(records);
|
|
1435
1449
|
this.datasets = new WebDatasetRefStore(records);
|
|
1436
|
-
this.
|
|
1450
|
+
this.calls = new WebFunctionCallStore(records);
|
|
1451
|
+
this.repos = new WebRepoStore(records, blobs, this.refs, this.datasets, this.calls, this.upgrades);
|
|
1437
1452
|
this.states = new WebStateStore(records);
|
|
1438
1453
|
}
|
|
1439
1454
|
/**
|