loro-repo 0.23.1 → 0.23.2
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/effect.cjs +14 -9
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.js +14 -9
- package/dist/effect.js.map +1 -1
- package/package.json +1 -1
package/dist/effect.cjs
CHANGED
|
@@ -1521,24 +1521,29 @@ const make = effect.Effect.fnUntraced(function* (options = {}) {
|
|
|
1521
1521
|
const reportFailure = (error) => effect.Effect.sync(() => {
|
|
1522
1522
|
for (const queue of failures) effect.Queue.offerUnsafe(queue, error);
|
|
1523
1523
|
});
|
|
1524
|
+
const runCompaction = (entry, compact) => effect.Effect.suspend(() => entry.compaction ? effect.Deferred.await(entry.compaction.done) : start(compactReplica(entry, compact), (job) => {
|
|
1525
|
+
entry.compaction = job;
|
|
1526
|
+
entry.work.add(job);
|
|
1527
|
+
return () => {
|
|
1528
|
+
entry.work.delete(job);
|
|
1529
|
+
if (entry.compaction === job) entry.compaction = void 0;
|
|
1530
|
+
};
|
|
1531
|
+
}).pipe(effect.Effect.flatMap(awaitJob)));
|
|
1524
1532
|
const armCompaction = (entry) => effect.Effect.suspend(() => {
|
|
1525
1533
|
const compact = compactor(entry);
|
|
1526
1534
|
if (!compact || !compactionBytes || entry.compactionArmed || closing || entry.retiring) return effect.Effect.void;
|
|
1527
1535
|
entry.compactionArmed = true;
|
|
1528
|
-
return effect.Effect.forkIn(effect.Effect.sleep(COMPACTION_DELAY_MS).pipe(effect.Effect.andThen(effect.Effect.suspend(() =>
|
|
1529
|
-
entry.work.add(job);
|
|
1530
|
-
return () => {
|
|
1531
|
-
entry.work.delete(job);
|
|
1532
|
-
};
|
|
1533
|
-
}).pipe(effect.Effect.flatMap(awaitJob)))), effect.Effect.catch(reportFailure), effect.Effect.ensuring(effect.Effect.sync(() => {
|
|
1536
|
+
return effect.Effect.forkIn(effect.Effect.sleep(COMPACTION_DELAY_MS).pipe(effect.Effect.andThen(effect.Effect.suspend(() => {
|
|
1534
1537
|
entry.compactionArmed = false;
|
|
1535
|
-
|
|
1538
|
+
return entry.released || entry.retiring || closing || !entry.updateBytes ? effect.Effect.void : runCompaction(entry, compact).pipe(effect.Effect.andThen(effect.Effect.suspend(() => entry.updateBytes && !entry.compactionFailed ? armCompaction(entry) : effect.Effect.void)));
|
|
1539
|
+
})), effect.Effect.catch(reportFailure)), backgroundScope).pipe(effect.Effect.asVoid);
|
|
1536
1540
|
});
|
|
1537
1541
|
const maintainJournal = (entry) => effect.Effect.suspend(() => {
|
|
1538
1542
|
if (entry.kind === "doc" || !entry.updateBytes) return effect.Effect.void;
|
|
1539
1543
|
const compact = compactor(entry);
|
|
1540
|
-
if (compact
|
|
1541
|
-
return
|
|
1544
|
+
if (!compact || !compactionBytes || entry.updateBytes < compactionBytes || entry.compactionFailed) return armCompaction(entry);
|
|
1545
|
+
if (entry.compaction) return effect.Deferred.await(entry.compaction.done).pipe(effect.Effect.andThen(effect.Effect.suspend(() => entry.retiring || entry.released ? effect.Effect.void : maintainJournal(entry))));
|
|
1546
|
+
return runCompaction(entry, compact).pipe(effect.Effect.catch((error) => reportFailure(error).pipe(effect.Effect.andThen(armCompaction(entry)))));
|
|
1542
1547
|
});
|
|
1543
1548
|
const markExistence = (entry) => {
|
|
1544
1549
|
if (!meta.value || entry.kind === "meta") return;
|