@milaboratories/pl-middle-layer 2.9.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/middle_layer/build_stamp.cjs +1 -1
- package/dist/middle_layer/build_stamp.js +1 -1
- package/dist/middle_layer/index.cjs +4 -0
- package/dist/middle_layer/index.d.ts +2 -1
- package/dist/middle_layer/index.js +2 -1
- package/dist/middle_layer/middle_layer.cjs +96 -28
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +54 -8
- package/dist/middle_layer/middle_layer.d.ts.map +1 -1
- package/dist/middle_layer/middle_layer.js +96 -28
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/dist/middle_layer/project.cjs +39 -17
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +17 -2
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project.js +39 -17
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/middle_layer/project_holds.cjs +266 -0
- package/dist/middle_layer/project_holds.cjs.map +1 -0
- package/dist/middle_layer/project_holds.d.ts +50 -0
- package/dist/middle_layer/project_holds.d.ts.map +1 -0
- package/dist/middle_layer/project_holds.js +262 -0
- package/dist/middle_layer/project_holds.js.map +1 -0
- package/package.json +6 -6
- package/src/middle_layer/index.ts +2 -0
- package/src/middle_layer/middle_layer.ts +117 -38
- package/src/middle_layer/project.ts +40 -15
- package/src/middle_layer/project_close_during_write.test.ts +142 -0
- package/src/middle_layer/project_handles.test.ts +168 -0
- package/src/middle_layer/project_holds.ts +359 -0
- package/src/middle_layer/project_slots.test.ts +331 -0
- package/src/test/write_tx_hooks.ts +75 -0
|
@@ -11,6 +11,7 @@ import { AvailableShare, OutgoingShare } from "./sharing_list.js";
|
|
|
11
11
|
import "../model/index.js";
|
|
12
12
|
import { BlockPackPreparer } from "../mutator/block-pack/block_pack.js";
|
|
13
13
|
import { Project } from "./project.js";
|
|
14
|
+
import { ProjectHandle, ProjectHolder } from "./project_holds.js";
|
|
14
15
|
import { MiddleLayerOps, MiddleLayerOpsConstructor } from "./ops.js";
|
|
15
16
|
import { BlockUpdateWatcher } from "../block_registry/watcher.js";
|
|
16
17
|
import { MiddleLayerDriverKit } from "./driver_kit.js";
|
|
@@ -407,8 +408,19 @@ export declare class MiddleLayer {
|
|
|
407
408
|
* Uses LRU cache with TX-scan fallback. */
|
|
408
409
|
private resolveTemplateId;
|
|
409
410
|
/** Permanently deletes project from the project list, this will result in
|
|
410
|
-
* destruction of all attached objects, like files, analysis results etc.
|
|
411
|
-
|
|
411
|
+
* destruction of all attached objects, like files, analysis results etc.
|
|
412
|
+
*
|
|
413
|
+
* A loaded project is taken from every holder: each {@link ProjectHandle} ends with `deleted`
|
|
414
|
+
* and the project is destroyed, with no snapshot. Holds do not prevent the delete unless
|
|
415
|
+
* `refuseIfHeldBy` is given. Holds taken during the delete end with it too.
|
|
416
|
+
*
|
|
417
|
+
* @param options.refuseIfHeldBy refuse the delete when it returns `true` for the label of any
|
|
418
|
+
* holder of the project.
|
|
419
|
+
* @throws {@link ProjectInUseError} when refused; the project is left as it was
|
|
420
|
+
*/
|
|
421
|
+
deleteProject(id: ProjectId$1, options?: {
|
|
422
|
+
refuseIfHeldBy?: (holder: ProjectHolder) => boolean;
|
|
423
|
+
}): Promise<void>;
|
|
412
424
|
/**
|
|
413
425
|
* Duplicates an existing project and adds the copy to this user's project list, beside the
|
|
414
426
|
* project it was copied from.
|
|
@@ -562,8 +574,11 @@ export declare class MiddleLayer {
|
|
|
562
574
|
/** Scans the donor's outbox and deletes expired envelopes (backend auto-revokes their grants).
|
|
563
575
|
* Envelopes with `expiresAt: null` (share-with-everybody) are skipped. */
|
|
564
576
|
private runEnvelopeCleanup;
|
|
565
|
-
|
|
566
|
-
|
|
577
|
+
/** The loaded projects and who holds them. */
|
|
578
|
+
private readonly projectSlots;
|
|
579
|
+
/** The holds taken by {@link openProject}, one per project, released by {@link closeProject}. */
|
|
580
|
+
private readonly legacyHolds;
|
|
581
|
+
/** Snapshot writes started by a project close and not yet finished. Held only so
|
|
567
582
|
* {@link close} can give them a bounded chance to land. */
|
|
568
583
|
private readonly pendingSnapshotWrites;
|
|
569
584
|
private trackSnapshotWrite;
|
|
@@ -574,13 +589,44 @@ export declare class MiddleLayer {
|
|
|
574
589
|
* does not routinely lose it. Bounded, because a wedged filesystem must not hang the quit,
|
|
575
590
|
* and losing the write costs one cold open rather than any correctness. */
|
|
576
591
|
private drainSnapshotWrites;
|
|
577
|
-
/**
|
|
592
|
+
/**
|
|
593
|
+
* Takes a hold on a project, loading it when nobody holds it yet. The project stays loaded until
|
|
594
|
+
* every hold is released, and is taken from all holders when it is deleted or the middle layer
|
|
595
|
+
* closes; the handle's `signal` says when and why.
|
|
596
|
+
*
|
|
597
|
+
* Concurrent acquires share one load. An acquire while the project is being destroyed waits for
|
|
598
|
+
* the destroy and loads the project anew, so there is never more than one {@link Project} per id.
|
|
599
|
+
*
|
|
600
|
+
* @param holder label for logs and {@link projectHolders}, e.g. `desktop` or `mcp:<instance>`
|
|
601
|
+
* @throws when the project is not in the project list, its load fails, or the middle layer is
|
|
602
|
+
* closed
|
|
603
|
+
*/
|
|
604
|
+
acquireProject(id: ProjectId$1, holder: ProjectHolder): Promise<ProjectHandle>;
|
|
605
|
+
/** Labels of the live holds on a project, one per hold; empty when nobody holds it. */
|
|
606
|
+
projectHolders(id: ProjectId$1): ProjectHolder[];
|
|
607
|
+
/**
|
|
608
|
+
* Opens a project, and starts corresponding project maintenance loop: takes a hold labelled
|
|
609
|
+
* `legacy`, which {@link closeProject} releases. Opening a project this API already holds does
|
|
610
|
+
* nothing.
|
|
611
|
+
*
|
|
612
|
+
* @deprecated use {@link acquireProject}, and release the handle
|
|
613
|
+
*/
|
|
578
614
|
openProject(id: ProjectId$1): Promise<void>;
|
|
579
|
-
/**
|
|
615
|
+
/**
|
|
616
|
+
* Releases the hold {@link openProject} took. The project is destroyed only when nobody else
|
|
617
|
+
* holds it. Closing a project this API does not hold does nothing.
|
|
618
|
+
*
|
|
619
|
+
* @deprecated use {@link ProjectHandle.release}
|
|
620
|
+
*/
|
|
580
621
|
closeProject(id: ProjectId$1): Promise<void>;
|
|
581
|
-
/**
|
|
622
|
+
/**
|
|
623
|
+
* Returns a project access object for a loaded project, whoever holds it.
|
|
624
|
+
*
|
|
625
|
+
* A caller holding no {@link ProjectHandle} must not keep the result across awaits: the project
|
|
626
|
+
* can be destroyed meanwhile.
|
|
627
|
+
*/
|
|
582
628
|
getOpenedProject(id: ProjectId$1): Project;
|
|
583
|
-
/** Returns true if project
|
|
629
|
+
/** Returns true if the project is currently loaded, whoever holds it. */
|
|
584
630
|
isProjectOpened(id: ProjectId$1): boolean;
|
|
585
631
|
/** Counters for the persisted project tree mirrors, or undefined when they are switched off.
|
|
586
632
|
* Reads and hits are what show whether a reopen was actually warm, and the miss breakdown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middle_layer.d.ts","names":["ProjectListEntry","ProjectId","TemplateId"],"sources":["../../src/middle_layer/middle_layer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"middle_layer.d.ts","names":["ProjectListEntry","ProjectId","TemplateId"],"sources":["../../src/middle_layer/middle_layer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwLiB;EACf,WAAW;WACF,IAAI;WACJ,qBAAqB;WACrB,QAAQ;WACR,sBAAsB;WACtB,gBAAgB;WAChB,qBAAqB;WACrB,QAAQ;WACR,KAAK;WACL,YAAY;WACZ,wBAAwB;WACxB,oBAAoB;WACpB,SAAS;WACT,WAAW;WACX,iBAAiB;WACjB,eAAe;;;WAGf,gBAAgB;;;;;;;;;;;;;;qBAed;mBAIQ;WACD,WAAW;WACX,QAAQ;mBACP;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBAC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,cAAY;;;;;;;;EAWzB,YAAY,IAAIA,cAAY;;;;;;;EAyB5B,aAAa,IAAIA,cAAY;;;;;;;EAgBnC,iBAAiB,IAAIA,cAAY;;EAOjC,gBAAgB,IAAIA;;;;MAOhB,qBAAqB,SAAS;;;;;;UASjC;;;;;;;MAQG,iBAAiB,WAAW;EAK1B,SAAK;;EAmBL,4BAAwB;;;SAMvB;;MAKH,wBAAwB;;SAKf,KAClB,IAAI,UACJ,iBACA,MAAM,4BACL,QAAQ"}
|
|
@@ -18,6 +18,7 @@ import { cacheBlockPackTemplate } from "../mutator/template/template_cache.js";
|
|
|
18
18
|
import { Project, throwIfMissingServerCapabilities } from "./project.js";
|
|
19
19
|
import { buildFolderShareEnvelope, buildShareEnvelope, buildTemplateShareEnvelope, clearShareHidden, copyEnvelopeProjectsIntoList, writeShareHidden } from "../mutator/sharing.js";
|
|
20
20
|
import { createAvailableSharesComputable, createAvailableSharesTree, createLiveEnvelopesComputable, createOutgoingShares, createSharingStateTree } from "./sharing_list.js";
|
|
21
|
+
import { ProjectSlots, asProjectHolder } from "./project_holds.js";
|
|
21
22
|
import { DefaultMiddleLayerOpsPaths, DefaultMiddleLayerOpsSettings } from "./ops.js";
|
|
22
23
|
import { BlockUpdateWatcher } from "../block_registry/watcher.js";
|
|
23
24
|
import { initDriverKit } from "./driver_kit.js";
|
|
@@ -39,6 +40,8 @@ import { getQuickJS } from "quickjs-emscripten";
|
|
|
39
40
|
* enough for a ten-megabyte encode and write on ordinary storage, short enough that a wedged
|
|
40
41
|
* filesystem does not hold the quit open. */
|
|
41
42
|
const SNAPSHOT_DRAIN_TIMEOUT_MS = 5e3;
|
|
43
|
+
/** The holder of the holds {@link MiddleLayer.openProject} takes. */
|
|
44
|
+
const LEGACY_HOLDER = asProjectHolder("legacy");
|
|
42
45
|
/**
|
|
43
46
|
* Main access object to work with pl from UI.
|
|
44
47
|
*
|
|
@@ -321,6 +324,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
321
324
|
for (const id of outcome.removal.projects) this.projectIdCache.delete(id);
|
|
322
325
|
for (const id of outcome.removal.templates) this.templateIdCache.delete(id);
|
|
323
326
|
await Promise.all([
|
|
327
|
+
...outcome.removal.projects.map((id) => this.projectSlots.evict(id, "deleted")),
|
|
324
328
|
this.foldersTree.refreshState(),
|
|
325
329
|
this.projectListTree.refreshState(),
|
|
326
330
|
this.templateListTree.refreshState()
|
|
@@ -818,15 +822,26 @@ var MiddleLayer = class MiddleLayer {
|
|
|
818
822
|
return rid;
|
|
819
823
|
}
|
|
820
824
|
/** Permanently deletes project from the project list, this will result in
|
|
821
|
-
* destruction of all attached objects, like files, analysis results etc.
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
825
|
+
* destruction of all attached objects, like files, analysis results etc.
|
|
826
|
+
*
|
|
827
|
+
* A loaded project is taken from every holder: each {@link ProjectHandle} ends with `deleted`
|
|
828
|
+
* and the project is destroyed, with no snapshot. Holds do not prevent the delete unless
|
|
829
|
+
* `refuseIfHeldBy` is given. Holds taken during the delete end with it too.
|
|
830
|
+
*
|
|
831
|
+
* @param options.refuseIfHeldBy refuse the delete when it returns `true` for the label of any
|
|
832
|
+
* holder of the project.
|
|
833
|
+
* @throws {@link ProjectInUseError} when refused; the project is left as it was
|
|
834
|
+
*/
|
|
835
|
+
async deleteProject(id, options = {}) {
|
|
836
|
+
await this.projectSlots.delete(id, async () => {
|
|
837
|
+
await this.pl.withWriteTx("MLRemoveProject", async (tx) => {
|
|
838
|
+
const entry = (await listedById(tx, this.projectListResourceId)).get(id);
|
|
839
|
+
if (entry === void 0) throw notListedError("Project", id);
|
|
840
|
+
tx.removeField(field(this.projectListResourceId, entry.fieldName));
|
|
841
|
+
await tx.commit();
|
|
842
|
+
});
|
|
843
|
+
this.projectIdCache.delete(id);
|
|
844
|
+
}, options.refuseIfHeldBy);
|
|
830
845
|
await this.projectListTree.refreshState();
|
|
831
846
|
}
|
|
832
847
|
/**
|
|
@@ -1282,8 +1297,19 @@ var MiddleLayer = class MiddleLayer {
|
|
|
1282
1297
|
this.env.logger.warn(`envelope cleanup failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1283
1298
|
}
|
|
1284
1299
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1300
|
+
/** The loaded projects and who holds them. */
|
|
1301
|
+
projectSlots = new ProjectSlots({
|
|
1302
|
+
load: async (id, onGone) => await Project.init(this.env, id, await this.resolveProjectId(id), onGone),
|
|
1303
|
+
trackSnapshotWrite: (write) => this.trackSnapshotWrite(write),
|
|
1304
|
+
publish: (open) => this.openedProjectsList.setValue(open),
|
|
1305
|
+
logger: {
|
|
1306
|
+
info: (msg) => this.env.logger.info(msg),
|
|
1307
|
+
warn: (msg) => this.env.logger.warn(msg)
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
/** The holds taken by {@link openProject}, one per project, released by {@link closeProject}. */
|
|
1311
|
+
legacyHolds = /* @__PURE__ */ new Map();
|
|
1312
|
+
/** Snapshot writes started by a project close and not yet finished. Held only so
|
|
1287
1313
|
* {@link close} can give them a bounded chance to land. */
|
|
1288
1314
|
pendingSnapshotWrites = /* @__PURE__ */ new Set();
|
|
1289
1315
|
trackSnapshotWrite(write) {
|
|
@@ -1309,31 +1335,73 @@ var MiddleLayer = class MiddleLayer {
|
|
|
1309
1335
|
if (timer !== void 0) clearTimeout(timer);
|
|
1310
1336
|
}
|
|
1311
1337
|
}
|
|
1312
|
-
/**
|
|
1338
|
+
/**
|
|
1339
|
+
* Takes a hold on a project, loading it when nobody holds it yet. The project stays loaded until
|
|
1340
|
+
* every hold is released, and is taken from all holders when it is deleted or the middle layer
|
|
1341
|
+
* closes; the handle's `signal` says when and why.
|
|
1342
|
+
*
|
|
1343
|
+
* Concurrent acquires share one load. An acquire while the project is being destroyed waits for
|
|
1344
|
+
* the destroy and loads the project anew, so there is never more than one {@link Project} per id.
|
|
1345
|
+
*
|
|
1346
|
+
* @param holder label for logs and {@link projectHolders}, e.g. `desktop` or `mcp:<instance>`
|
|
1347
|
+
* @throws when the project is not in the project list, its load fails, or the middle layer is
|
|
1348
|
+
* closed
|
|
1349
|
+
*/
|
|
1350
|
+
async acquireProject(id, holder) {
|
|
1351
|
+
return await this.projectSlots.acquire(id, holder);
|
|
1352
|
+
}
|
|
1353
|
+
/** Labels of the live holds on a project, one per hold; empty when nobody holds it. */
|
|
1354
|
+
projectHolders(id) {
|
|
1355
|
+
return this.projectSlots.holders(id);
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Opens a project, and starts corresponding project maintenance loop: takes a hold labelled
|
|
1359
|
+
* `legacy`, which {@link closeProject} releases. Opening a project this API already holds does
|
|
1360
|
+
* nothing.
|
|
1361
|
+
*
|
|
1362
|
+
* @deprecated use {@link acquireProject}, and release the handle
|
|
1363
|
+
*/
|
|
1313
1364
|
async openProject(id) {
|
|
1314
|
-
if (this.
|
|
1315
|
-
const
|
|
1316
|
-
this.
|
|
1317
|
-
|
|
1365
|
+
if (this.legacyHolds.get(id)?.ended === false) return;
|
|
1366
|
+
const handle = await this.projectSlots.acquire(id, LEGACY_HOLDER);
|
|
1367
|
+
if (this.legacyHolds.get(id)?.ended === false) {
|
|
1368
|
+
await handle.release();
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
this.legacyHolds.set(id, handle);
|
|
1372
|
+
handle.signal.addEventListener("abort", () => {
|
|
1373
|
+
if (this.legacyHolds.get(id) === handle) this.legacyHolds.delete(id);
|
|
1374
|
+
}, { once: true });
|
|
1318
1375
|
}
|
|
1319
|
-
/**
|
|
1376
|
+
/**
|
|
1377
|
+
* Releases the hold {@link openProject} took. The project is destroyed only when nobody else
|
|
1378
|
+
* holds it. Closing a project this API does not hold does nothing.
|
|
1379
|
+
*
|
|
1380
|
+
* @deprecated use {@link ProjectHandle.release}
|
|
1381
|
+
*/
|
|
1320
1382
|
async closeProject(id) {
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1383
|
+
const handle = this.legacyHolds.get(id);
|
|
1384
|
+
this.legacyHolds.delete(id);
|
|
1385
|
+
if (handle === void 0 || handle.ended) {
|
|
1386
|
+
this.env.logger.info(`closeProject: project ${id} is not held by openProject`);
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
await handle.release();
|
|
1327
1390
|
}
|
|
1328
|
-
/**
|
|
1391
|
+
/**
|
|
1392
|
+
* Returns a project access object for a loaded project, whoever holds it.
|
|
1393
|
+
*
|
|
1394
|
+
* A caller holding no {@link ProjectHandle} must not keep the result across awaits: the project
|
|
1395
|
+
* can be destroyed meanwhile.
|
|
1396
|
+
*/
|
|
1329
1397
|
getOpenedProject(id) {
|
|
1330
|
-
const prj = this.
|
|
1398
|
+
const prj = this.projectSlots.get(id);
|
|
1331
1399
|
if (prj === void 0) throw new Error(`Project ${id} not found among opened projects`);
|
|
1332
1400
|
return prj;
|
|
1333
1401
|
}
|
|
1334
|
-
/** Returns true if project
|
|
1402
|
+
/** Returns true if the project is currently loaded, whoever holds it. */
|
|
1335
1403
|
isProjectOpened(id) {
|
|
1336
|
-
return this.
|
|
1404
|
+
return this.projectSlots.get(id) !== void 0;
|
|
1337
1405
|
}
|
|
1338
1406
|
/** Counters for the persisted project tree mirrors, or undefined when they are switched off.
|
|
1339
1407
|
* Reads and hits are what show whether a reopen was actually warm, and the miss breakdown
|
|
@@ -1360,7 +1428,7 @@ var MiddleLayer = class MiddleLayer {
|
|
|
1360
1428
|
async close() {
|
|
1361
1429
|
if (this.envelopeCleanupTimer !== void 0) clearInterval(this.envelopeCleanupTimer);
|
|
1362
1430
|
await this.instanceStatsWatch?.terminate();
|
|
1363
|
-
await
|
|
1431
|
+
await this.projectSlots.closeAll();
|
|
1364
1432
|
await Promise.all([
|
|
1365
1433
|
this.projectListTree.terminate(),
|
|
1366
1434
|
this.templateListTree.terminate(),
|