@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.32 → 6.2.3-dev.33
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as errorToInfo, t as createForwardingLogger, u as instrumentPgPool } from "./forwarding-logger-
|
|
2
|
-
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor-
|
|
1
|
+
import { n as errorToInfo, t as createForwardingLogger, u as instrumentPgPool } from "./forwarding-logger-BkwlvD9W.js";
|
|
2
|
+
import { n as defaultLoadFactory, t as buildWorkerExecutor } from "./build-worker-executor-BonPsKdx.js";
|
|
3
3
|
import { ConsoleLogger } from "document-model";
|
|
4
4
|
import { isMainThread, parentPort } from "node:worker_threads";
|
|
5
5
|
//#region src/executor/worker/run-worker.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { a as KyselyDocumentView, c as ReadModelCoordinator, n as ConsistencyTracker, t as KyselyDocumentIndexer } from "./document-indexer-
|
|
3
|
-
import { n as defaultLoadFactory } from "./build-worker-executor-
|
|
1
|
+
import { C as SettledWatermark, O as DocumentMetaCache, b as KyselyWriteCache, d as KyselyOperationStore, f as KyselyKeyframeStore, k as CollectionMembershipCache, mt as ReactorEventTypes, n as errorToInfo, o as REACTOR_SCHEMA, p as DocumentModelRegistry, t as createForwardingLogger, u as instrumentPgPool, w as createKyselyWatermarkProbe, x as KyselyOperationIndex, y as EventBus } from "./forwarding-logger-BkwlvD9W.js";
|
|
2
|
+
import { a as KyselyDocumentView, c as ReadModelCoordinator, f as BaseReadModel, n as ConsistencyTracker, t as KyselyDocumentIndexer, y as CatchUpScheduler } from "./document-indexer-I6i_YzsR.js";
|
|
3
|
+
import { n as defaultLoadFactory } from "./build-worker-executor-BonPsKdx.js";
|
|
4
4
|
import { ConsoleLogger } from "document-model";
|
|
5
5
|
import { isMainThread, parentPort } from "node:worker_threads";
|
|
6
6
|
//#region src/projection/projection-worker/build-projection-stack.ts
|
|
@@ -39,6 +39,31 @@ async function initReadModels(models, logger) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
/** Posts what each sweep applied, so the host's tracker for the model advances. */
|
|
43
|
+
function relaySweeps(model, events) {
|
|
44
|
+
return {
|
|
45
|
+
get consumerId() {
|
|
46
|
+
return model.consumerId;
|
|
47
|
+
},
|
|
48
|
+
get appliedThrough() {
|
|
49
|
+
return model.appliedThrough;
|
|
50
|
+
},
|
|
51
|
+
get trackedAbove() {
|
|
52
|
+
return model.trackedAbove;
|
|
53
|
+
},
|
|
54
|
+
async sweep(settledThrough, present, signal) {
|
|
55
|
+
const coordinates = [];
|
|
56
|
+
const unsubscribe = model.onSwept((swept) => coordinates.push(...swept));
|
|
57
|
+
try {
|
|
58
|
+
const result = await model.sweep(settledThrough, present, signal);
|
|
59
|
+
if (coordinates.length > 0 || result.to > result.from || result.replayed > 0 || result.blockedAt !== void 0) events.onReadModelSwept(model.name, coordinates, result);
|
|
60
|
+
return result;
|
|
61
|
+
} finally {
|
|
62
|
+
unsubscribe();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
42
67
|
async function buildProjectionStack(options) {
|
|
43
68
|
const { init, database: baseDatabase, logger, events } = options;
|
|
44
69
|
const loadFactory = options.loadFactory ?? defaultLoadFactory;
|
|
@@ -58,7 +83,13 @@ async function buildProjectionStack(options) {
|
|
|
58
83
|
new CollectionMembershipCache(operationIndex);
|
|
59
84
|
const preReady = init.preReadyKinds.map((kind) => instantiateReadModel(kind, database, operationStore, operationIndex, writeCache, init.indexing));
|
|
60
85
|
const postReady = init.postReadyKinds.map((kind) => instantiateReadModel(kind, database, operationStore, operationIndex, writeCache, init.indexing));
|
|
61
|
-
|
|
86
|
+
const watermark = new SettledWatermark(createKyselyWatermarkProbe(database), logger);
|
|
87
|
+
const catchUp = new CatchUpScheduler(watermark, operationIndex, init.catchUp, logger);
|
|
88
|
+
const models = [...preReady, ...postReady];
|
|
89
|
+
for (const model of models) if (model instanceof BaseReadModel) model.attachCatchUp(watermark, init.catchUp.maxTrackedAboveCursor);
|
|
90
|
+
await initReadModels(models, logger);
|
|
91
|
+
for (const model of models) if (model instanceof BaseReadModel) catchUp.addConsumer(relaySweeps(model, events), "projection");
|
|
92
|
+
catchUp.start();
|
|
62
93
|
const eventBus = new EventBus();
|
|
63
94
|
const subscriptions = [];
|
|
64
95
|
subscriptions.push(eventBus.subscribe(ReactorEventTypes.JOB_READ_READY, (_t, event) => {
|
|
@@ -82,13 +113,16 @@ async function buildProjectionStack(options) {
|
|
|
82
113
|
getChainDepth() {
|
|
83
114
|
return coordinator.getChainDepth();
|
|
84
115
|
},
|
|
116
|
+
catchUpStatus() {
|
|
117
|
+
return catchUp.status();
|
|
118
|
+
},
|
|
85
119
|
async drain() {
|
|
86
120
|
await coordinator.drain();
|
|
87
121
|
},
|
|
88
|
-
shutdown() {
|
|
122
|
+
async shutdown() {
|
|
123
|
+
await catchUp.stop();
|
|
89
124
|
coordinator.stop();
|
|
90
125
|
for (const unsub of subscriptions) unsub();
|
|
91
|
-
return Promise.resolve();
|
|
92
126
|
}
|
|
93
127
|
};
|
|
94
128
|
}
|
|
@@ -209,6 +243,11 @@ function runProjectionWorker(parentPort, overrides = {}) {
|
|
|
209
243
|
if (intervalMs <= 0) return;
|
|
210
244
|
depthTimer = setInterval(() => {
|
|
211
245
|
if (!stack) return;
|
|
246
|
+
post({
|
|
247
|
+
type: "catchup-status",
|
|
248
|
+
shardId,
|
|
249
|
+
status: stack.catchUpStatus()
|
|
250
|
+
});
|
|
212
251
|
const depth = stack.getChainDepth();
|
|
213
252
|
if (depth === lastReportedDepth) return;
|
|
214
253
|
lastReportedDepth = depth;
|
|
@@ -257,6 +296,15 @@ function runProjectionWorker(parentPort, overrides = {}) {
|
|
|
257
296
|
success: event.success
|
|
258
297
|
});
|
|
259
298
|
},
|
|
299
|
+
onReadModelSwept: (readModelName, coordinates, result) => {
|
|
300
|
+
post({
|
|
301
|
+
type: "readmodel-swept",
|
|
302
|
+
shardId,
|
|
303
|
+
readModelName,
|
|
304
|
+
coordinates,
|
|
305
|
+
result
|
|
306
|
+
});
|
|
307
|
+
},
|
|
260
308
|
onBatchCompleted: (event) => {
|
|
261
309
|
post({
|
|
262
310
|
type: "readmodel-batch-completed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/powerhouse-vetra-packages",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"@codemirror/view": "6.36.7",
|
|
82
82
|
"@graphql-tools/utils": "11.0.0",
|
|
83
83
|
"@hookform/resolvers": "^5.0.1",
|
|
84
|
-
"@powerhousedao/design-system": "6.2.3-dev.
|
|
84
|
+
"@powerhousedao/design-system": "6.2.3-dev.33",
|
|
85
85
|
"@powerhousedao/document-engineering": "1.40.5",
|
|
86
|
-
"@powerhousedao/reactor-browser": "6.2.3-dev.
|
|
87
|
-
"@powerhousedao/reactor-drive": "6.2.3-dev.
|
|
88
|
-
"@powerhousedao/reactor-group": "6.2.3-dev.
|
|
89
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
86
|
+
"@powerhousedao/reactor-browser": "6.2.3-dev.33",
|
|
87
|
+
"@powerhousedao/reactor-drive": "6.2.3-dev.33",
|
|
88
|
+
"@powerhousedao/reactor-group": "6.2.3-dev.33",
|
|
89
|
+
"@powerhousedao/shared": "6.2.3-dev.33",
|
|
90
90
|
"@radix-ui/react-label": "^2.1.4",
|
|
91
91
|
"@radix-ui/react-slot": "^1.2.0",
|
|
92
92
|
"@radix-ui/react-tabs": "^1.1.9",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"class-variance-authority": "0.7.0",
|
|
99
99
|
"clsx": "^2.1.1",
|
|
100
100
|
"cm6-graphql": "^0.2.1",
|
|
101
|
-
"document-model": "6.2.3-dev.
|
|
101
|
+
"document-model": "6.2.3-dev.33",
|
|
102
102
|
"graphql": "^16",
|
|
103
103
|
"react": "19.2.6",
|
|
104
104
|
"react-dom": "19.2.6",
|