@reventlessdev/reventless-local 3.0.0-alpha.114 → 3.0.0-alpha.116
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 +30 -0
- package/package.json +8 -8
- package/src/Platform.res +116 -67
- package/src/Platform.res.mjs +114 -190
- package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res +102 -17
- package/src/adapter/DcbEventLog/DcbEventLogStorage_InMemory.res.mjs +105 -22
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res +123 -40
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Sqlite.res.mjs +96 -24
- package/src/adapter/EventCollector/LocalEventCollectorChannel.res +33 -0
- package/src/adapter/EventCollector/LocalEventCollectorChannel.res.mjs +44 -0
- package/src/adapter/EventLog/EventLogStorage_InMemory.res +24 -3
- package/src/adapter/EventLog/EventLogStorage_InMemory.res.mjs +21 -4
- package/src/adapter/EventLog/EventLogStorage_Sqlite.res +148 -27
- package/src/adapter/EventLog/EventLogStorage_Sqlite.res.mjs +144 -34
- package/src/adapter/LocalBus.res +85 -3
- package/src/adapter/LocalBus.res.mjs +220 -66
- package/src/adapter/ProjectionCheckpoint.res +350 -0
- package/src/adapter/ProjectionCheckpoint.res.mjs +327 -0
- package/src/adapter/ProjectionPending.res +60 -0
- package/src/adapter/ProjectionPending.res.mjs +64 -0
- package/src/adapter/QueryDb/QueryDbListQuery.res +261 -0
- package/src/adapter/QueryDb/QueryDbListQuery.res.mjs +212 -0
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res +54 -286
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res.mjs +28 -190
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res +128 -10
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res.mjs +123 -23
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res +187 -12
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res.mjs +120 -7
- package/src/adapter/SqliteDriver.res +17 -2
- package/src/adapter/SqliteDriver.res.mjs +10 -2
- package/src/components/DcbEventLog_Builder.res +7 -1
- package/src/components/DcbEventLog_Builder.res.mjs +3 -3
- package/src/components/ReadModel_Builder.res +3 -1
- package/src/components/ReadModel_Builder.res.mjs +13 -4
- package/src/components/StateViewSlice_Builder.res +4 -1
- package/src/components/StateViewSlice_Builder.res.mjs +9 -3
- package/src/test/Mocks/MockEventLogStorage.res +20 -3
- package/src/test/Mocks/MockEventLogStorage.res.mjs +25 -3
- package/tests/PluginEventDecodeTest.res +51 -0
- package/tests/PluginEventDecodeTest.res.mjs +63 -0
- package/tests/adapter/BackendParityTest.res +64 -0
- package/tests/adapter/BackendParityTest.res.mjs +45 -0
- package/tests/adapter/DcbEventLogStorageSqliteTest.res +73 -0
- package/tests/adapter/DcbEventLogStorageSqliteTest.res.mjs +86 -0
- package/tests/adapter/DcbEventLogStorageTest.res +46 -0
- package/tests/adapter/DcbEventLogStorageTest.res.mjs +63 -0
- package/tests/adapter/EventLogSnapshotParityTest.res +81 -0
- package/tests/adapter/EventLogSnapshotParityTest.res.mjs +141 -0
- package/tests/adapter/EventLogStorageSqliteTest.res +132 -2
- package/tests/adapter/EventLogStorageSqliteTest.res.mjs +195 -1
- package/tests/adapter/LocalBusPubSubTest.res +31 -0
- package/tests/adapter/LocalBusPubSubTest.res.mjs +28 -0
- package/tests/adapter/ProjectionCheckpointTest.res +422 -0
- package/tests/adapter/ProjectionCheckpointTest.res.mjs +401 -0
- package/tests/adapter/QueryDbGsiTtlTest.res +78 -0
- package/tests/adapter/QueryDbGsiTtlTest.res.mjs +77 -0
- package/tests/adapter/QueryDbListPushdownParityTest.res +197 -0
- package/tests/adapter/QueryDbListPushdownParityTest.res.mjs +292 -0
- package/tests/adapter/QueryDbListResolverTest.res +76 -0
- package/tests/adapter/QueryDbListResolverTest.res.mjs +84 -0
- package/tests/components/aggregate/AggregateFixtures.res +4 -0
- package/tests/components/aggregate/AggregateFixtures.res.mjs +1 -0
- package/tests/components/eventlog/EventLogAppendStreamTest.res.mjs +4 -4
- package/tests/components/eventlog/EventLogStreamTest.res.mjs +8 -8
- package/tests/plugin/PluginBehavior_GWT.res.mjs +1 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
|
|
3
4
|
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
4
5
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
5
6
|
import * as Queue from "effect/Queue";
|
|
6
7
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Effect$1 from "effect/Effect";
|
|
8
9
|
import * as PubSub from "effect/PubSub";
|
|
9
10
|
import * as Stream from "effect/Stream";
|
|
11
|
+
import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
|
|
10
12
|
import * as Deferred from "effect/Deferred";
|
|
11
13
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
12
14
|
|
|
@@ -102,6 +104,12 @@ function Impl(C) {
|
|
|
102
104
|
let queryDbStreamRegistry = {
|
|
103
105
|
contents: {}
|
|
104
106
|
};
|
|
107
|
+
let queryDbIndexLookupRegistry = {
|
|
108
|
+
contents: {}
|
|
109
|
+
};
|
|
110
|
+
let queryDbListPageRegistry = {
|
|
111
|
+
contents: {}
|
|
112
|
+
};
|
|
105
113
|
let eventLogReplayRegistry = {
|
|
106
114
|
contents: {}
|
|
107
115
|
};
|
|
@@ -110,9 +118,9 @@ function Impl(C) {
|
|
|
110
118
|
};
|
|
111
119
|
let makeHub = () => {
|
|
112
120
|
if (capacity !== undefined) {
|
|
113
|
-
return Effect.runSync(PubSub.bounded(capacity));
|
|
121
|
+
return Effect$1.runSync(PubSub.bounded(capacity));
|
|
114
122
|
} else {
|
|
115
|
-
return Effect.runSync(PubSub.unbounded());
|
|
123
|
+
return Effect$1.runSync(PubSub.unbounded());
|
|
116
124
|
}
|
|
117
125
|
};
|
|
118
126
|
let subscribeToEvents = (topicName, handler) => {
|
|
@@ -127,8 +135,10 @@ function Impl(C) {
|
|
|
127
135
|
}
|
|
128
136
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
129
137
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
130
|
-
let drainLoop = Effect.scoped(Effect.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect.
|
|
131
|
-
|
|
138
|
+
let drainLoop = Effect$1.scoped(Effect$1.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect$1.ensuring(Effect$1.catchAll(Effect.tryPromise(e => e, () => handler(msg.service, msg.meta, msg.json)), err => Effect$1.sync(() => {
|
|
139
|
+
console.error("[LocalBus] subscriber handler failed:", err);
|
|
140
|
+
})), msg.done_))));
|
|
141
|
+
Effect$1.runFork(drainLoop);
|
|
132
142
|
};
|
|
133
143
|
let subscribeToEventStream = topicName => {
|
|
134
144
|
let h = eventHubs.contents[topicName];
|
|
@@ -140,10 +150,10 @@ function Impl(C) {
|
|
|
140
150
|
eventHubs.contents[topicName] = h$1;
|
|
141
151
|
hub = h$1;
|
|
142
152
|
}
|
|
143
|
-
return Effect.map(Effect.acquireRelease(Effect.flatMap(Effect.sync(() => {
|
|
153
|
+
return Effect$1.map(Effect$1.acquireRelease(Effect$1.flatMap(Effect$1.sync(() => {
|
|
144
154
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
145
155
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
146
|
-
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect.zipRight(Effect.sync(() => {
|
|
156
|
+
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect$1.zipRight(Effect$1.sync(() => {
|
|
147
157
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 1);
|
|
148
158
|
subscriberCounts.contents[topicName] = n - 1 | 0;
|
|
149
159
|
}), Queue.shutdown(queue))), queue => Stream.fromQueue(queue));
|
|
@@ -161,17 +171,17 @@ function Impl(C) {
|
|
|
161
171
|
if (n === 0) {
|
|
162
172
|
return;
|
|
163
173
|
}
|
|
164
|
-
let allDone = Effect.runSync(Deferred.make());
|
|
174
|
+
let allDone = Effect$1.runSync(Deferred.make());
|
|
165
175
|
let remaining = {
|
|
166
176
|
contents: n
|
|
167
177
|
};
|
|
168
|
-
let done_ = Effect.flatMap(Effect.sync(() => {
|
|
178
|
+
let done_ = Effect$1.flatMap(Effect$1.sync(() => {
|
|
169
179
|
remaining.contents = remaining.contents - 1 | 0;
|
|
170
180
|
}), () => {
|
|
171
181
|
if (remaining.contents === 0) {
|
|
172
|
-
return Effect.map(Deferred.succeed(allDone, undefined), param => {});
|
|
182
|
+
return Effect$1.map(Deferred.succeed(allDone, undefined), param => {});
|
|
173
183
|
} else {
|
|
174
|
-
return Effect.succeed();
|
|
184
|
+
return Effect$1.succeed();
|
|
175
185
|
}
|
|
176
186
|
});
|
|
177
187
|
let msg = {
|
|
@@ -180,10 +190,10 @@ function Impl(C) {
|
|
|
180
190
|
json: json,
|
|
181
191
|
done_: done_
|
|
182
192
|
};
|
|
183
|
-
let publishAndWait = capacity !== undefined ? Effect.flatMap(PubSub.publish(hub$1, msg), param => Deferred.await(allDone)) : Effect.zipRight(Effect.sync(() => {
|
|
184
|
-
Effect.runSync(PubSub.publish(hub$1, msg));
|
|
193
|
+
let publishAndWait = capacity !== undefined ? Effect$1.flatMap(PubSub.publish(hub$1, msg), param => Deferred.await(allDone)) : Effect$1.zipRight(Effect$1.sync(() => {
|
|
194
|
+
Effect$1.runSync(PubSub.publish(hub$1, msg));
|
|
185
195
|
}), Deferred.await(allDone));
|
|
186
|
-
await Effect.runPromise(publishAndWait);
|
|
196
|
+
await Effect$1.runPromise(publishAndWait);
|
|
187
197
|
};
|
|
188
198
|
let dispatchCommand = async (channelName, json) => {
|
|
189
199
|
let handler = commandHandlers.contents[channelName];
|
|
@@ -212,7 +222,10 @@ function Impl(C) {
|
|
|
212
222
|
let pending = queue.contents;
|
|
213
223
|
queue.contents = [];
|
|
214
224
|
pending.forEach(json => {
|
|
215
|
-
handler(json, undefined)
|
|
225
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
226
|
+
console.error("[LocalBus] parked command handler failed:", e);
|
|
227
|
+
return Promise.resolve();
|
|
228
|
+
});
|
|
216
229
|
});
|
|
217
230
|
};
|
|
218
231
|
let registerQueryDb = (name, ops) => {
|
|
@@ -227,6 +240,14 @@ function Impl(C) {
|
|
|
227
240
|
queryDbStreamRegistry.contents[name] = streamFn;
|
|
228
241
|
};
|
|
229
242
|
let getQueryDbStream = name => queryDbStreamRegistry.contents[name];
|
|
243
|
+
let registerQueryDbIndexLookup = (name, lookup) => {
|
|
244
|
+
queryDbIndexLookupRegistry.contents[name] = lookup;
|
|
245
|
+
};
|
|
246
|
+
let getQueryDbIndexLookup = name => queryDbIndexLookupRegistry.contents[name];
|
|
247
|
+
let registerQueryDbListPage = (name, listPage) => {
|
|
248
|
+
queryDbListPageRegistry.contents[name] = listPage;
|
|
249
|
+
};
|
|
250
|
+
let getQueryDbListPage = name => queryDbListPageRegistry.contents[name];
|
|
230
251
|
let registerEventLogReplay = (name, replay) => {
|
|
231
252
|
eventLogReplayRegistry.contents[name] = replay;
|
|
232
253
|
};
|
|
@@ -252,7 +273,10 @@ function Impl(C) {
|
|
|
252
273
|
contents: {}
|
|
253
274
|
};
|
|
254
275
|
let makeFireAndForgetHandler = handler => ((param, param$1, json) => {
|
|
255
|
-
handler(json, undefined)
|
|
276
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
277
|
+
console.error("[LocalBus] fire-and-forget handler failed:", e);
|
|
278
|
+
return Promise.resolve();
|
|
279
|
+
});
|
|
256
280
|
return Promise.resolve();
|
|
257
281
|
});
|
|
258
282
|
let registerEventCollectorHandler = (ecName, handler) => {
|
|
@@ -272,11 +296,18 @@ function Impl(C) {
|
|
|
272
296
|
pending.push(topicName);
|
|
273
297
|
eventCollectorPendingTopics.contents[ecName] = pending;
|
|
274
298
|
};
|
|
299
|
+
let projectionCatchupRegistry = {
|
|
300
|
+
contents: {}
|
|
301
|
+
};
|
|
302
|
+
let registerProjectionCatchupHandler = (name, handler) => {
|
|
303
|
+
projectionCatchupRegistry.contents[name] = handler;
|
|
304
|
+
};
|
|
305
|
+
let projectionCatchupHandlers = () => Object.entries(projectionCatchupRegistry.contents);
|
|
275
306
|
let reset = () => {
|
|
276
|
-
let shutdownAll = Effect.map(Effect.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
307
|
+
let shutdownAll = Effect$1.map(Effect$1.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
277
308
|
concurrency: "unbounded"
|
|
278
309
|
}), param => {});
|
|
279
|
-
Effect.runSync(shutdownAll);
|
|
310
|
+
Effect$1.runSync(shutdownAll);
|
|
280
311
|
eventHubs.contents = {};
|
|
281
312
|
subscriberCounts.contents = {};
|
|
282
313
|
commandHandlers.contents = {};
|
|
@@ -284,11 +315,14 @@ function Impl(C) {
|
|
|
284
315
|
queryDbRegistry.contents = {};
|
|
285
316
|
queryDbScanRegistry.contents = {};
|
|
286
317
|
queryDbStreamRegistry.contents = {};
|
|
318
|
+
queryDbIndexLookupRegistry.contents = {};
|
|
319
|
+
queryDbListPageRegistry.contents = {};
|
|
287
320
|
eventLogReplayRegistry.contents = {};
|
|
288
321
|
dcbEventLogReadRegistry.contents = {};
|
|
289
322
|
stateChangeListeners.contents = {};
|
|
290
323
|
eventCollectorHandlers.contents = {};
|
|
291
324
|
eventCollectorPendingTopics.contents = {};
|
|
325
|
+
projectionCatchupRegistry.contents = {};
|
|
292
326
|
};
|
|
293
327
|
return {
|
|
294
328
|
publishEvent: publishEvent,
|
|
@@ -302,6 +336,10 @@ function Impl(C) {
|
|
|
302
336
|
getQueryDbScan: getQueryDbScan,
|
|
303
337
|
registerQueryDbStream: registerQueryDbStream,
|
|
304
338
|
getQueryDbStream: getQueryDbStream,
|
|
339
|
+
registerQueryDbIndexLookup: registerQueryDbIndexLookup,
|
|
340
|
+
getQueryDbIndexLookup: getQueryDbIndexLookup,
|
|
341
|
+
registerQueryDbListPage: registerQueryDbListPage,
|
|
342
|
+
getQueryDbListPage: getQueryDbListPage,
|
|
305
343
|
registerEventLogReplay: registerEventLogReplay,
|
|
306
344
|
getEventLogReplay: getEventLogReplay,
|
|
307
345
|
registerDcbEventLogRead: registerDcbEventLogRead,
|
|
@@ -310,6 +348,8 @@ function Impl(C) {
|
|
|
310
348
|
subscribeToStateChanges: subscribeToStateChanges,
|
|
311
349
|
registerEventCollectorHandler: registerEventCollectorHandler,
|
|
312
350
|
subscribeEventCollectorToTopic: subscribeEventCollectorToTopic,
|
|
351
|
+
registerProjectionCatchupHandler: registerProjectionCatchupHandler,
|
|
352
|
+
projectionCatchupHandlers: projectionCatchupHandlers,
|
|
313
353
|
reset: reset
|
|
314
354
|
};
|
|
315
355
|
}
|
|
@@ -336,13 +376,19 @@ function Make($star) {
|
|
|
336
376
|
let queryDbStreamRegistry = {
|
|
337
377
|
contents: {}
|
|
338
378
|
};
|
|
379
|
+
let queryDbIndexLookupRegistry = {
|
|
380
|
+
contents: {}
|
|
381
|
+
};
|
|
382
|
+
let queryDbListPageRegistry = {
|
|
383
|
+
contents: {}
|
|
384
|
+
};
|
|
339
385
|
let eventLogReplayRegistry = {
|
|
340
386
|
contents: {}
|
|
341
387
|
};
|
|
342
388
|
let dcbEventLogReadRegistry = {
|
|
343
389
|
contents: {}
|
|
344
390
|
};
|
|
345
|
-
let makeHub = () => Effect.runSync(PubSub.unbounded());
|
|
391
|
+
let makeHub = () => Effect$1.runSync(PubSub.unbounded());
|
|
346
392
|
let subscribeToEvents = (topicName, handler) => {
|
|
347
393
|
let h = eventHubs.contents[topicName];
|
|
348
394
|
let hub;
|
|
@@ -355,8 +401,10 @@ function Make($star) {
|
|
|
355
401
|
}
|
|
356
402
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
357
403
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
358
|
-
let drainLoop = Effect.scoped(Effect.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect.
|
|
359
|
-
|
|
404
|
+
let drainLoop = Effect$1.scoped(Effect$1.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect$1.ensuring(Effect$1.catchAll(Effect.tryPromise(e => e, () => handler(msg.service, msg.meta, msg.json)), err => Effect$1.sync(() => {
|
|
405
|
+
console.error("[LocalBus] subscriber handler failed:", err);
|
|
406
|
+
})), msg.done_))));
|
|
407
|
+
Effect$1.runFork(drainLoop);
|
|
360
408
|
};
|
|
361
409
|
let subscribeToEventStream = topicName => {
|
|
362
410
|
let h = eventHubs.contents[topicName];
|
|
@@ -368,10 +416,10 @@ function Make($star) {
|
|
|
368
416
|
eventHubs.contents[topicName] = h$1;
|
|
369
417
|
hub = h$1;
|
|
370
418
|
}
|
|
371
|
-
return Effect.map(Effect.acquireRelease(Effect.flatMap(Effect.sync(() => {
|
|
419
|
+
return Effect$1.map(Effect$1.acquireRelease(Effect$1.flatMap(Effect$1.sync(() => {
|
|
372
420
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
373
421
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
374
|
-
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect.zipRight(Effect.sync(() => {
|
|
422
|
+
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect$1.zipRight(Effect$1.sync(() => {
|
|
375
423
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 1);
|
|
376
424
|
subscriberCounts.contents[topicName] = n - 1 | 0;
|
|
377
425
|
}), Queue.shutdown(queue))), queue => Stream.fromQueue(queue));
|
|
@@ -389,17 +437,17 @@ function Make($star) {
|
|
|
389
437
|
if (n === 0) {
|
|
390
438
|
return;
|
|
391
439
|
}
|
|
392
|
-
let allDone = Effect.runSync(Deferred.make());
|
|
440
|
+
let allDone = Effect$1.runSync(Deferred.make());
|
|
393
441
|
let remaining = {
|
|
394
442
|
contents: n
|
|
395
443
|
};
|
|
396
|
-
let done_ = Effect.flatMap(Effect.sync(() => {
|
|
444
|
+
let done_ = Effect$1.flatMap(Effect$1.sync(() => {
|
|
397
445
|
remaining.contents = remaining.contents - 1 | 0;
|
|
398
446
|
}), () => {
|
|
399
447
|
if (remaining.contents === 0) {
|
|
400
|
-
return Effect.map(Deferred.succeed(allDone, undefined), param => {});
|
|
448
|
+
return Effect$1.map(Deferred.succeed(allDone, undefined), param => {});
|
|
401
449
|
} else {
|
|
402
|
-
return Effect.succeed();
|
|
450
|
+
return Effect$1.succeed();
|
|
403
451
|
}
|
|
404
452
|
});
|
|
405
453
|
let msg = {
|
|
@@ -408,10 +456,10 @@ function Make($star) {
|
|
|
408
456
|
json: json,
|
|
409
457
|
done_: done_
|
|
410
458
|
};
|
|
411
|
-
let publishAndWait = Effect.zipRight(Effect.sync(() => {
|
|
412
|
-
Effect.runSync(PubSub.publish(hub$1, msg));
|
|
459
|
+
let publishAndWait = Effect$1.zipRight(Effect$1.sync(() => {
|
|
460
|
+
Effect$1.runSync(PubSub.publish(hub$1, msg));
|
|
413
461
|
}), Deferred.await(allDone));
|
|
414
|
-
await Effect.runPromise(publishAndWait);
|
|
462
|
+
await Effect$1.runPromise(publishAndWait);
|
|
415
463
|
};
|
|
416
464
|
let dispatchCommand = async (channelName, json) => {
|
|
417
465
|
let handler = commandHandlers.contents[channelName];
|
|
@@ -440,7 +488,10 @@ function Make($star) {
|
|
|
440
488
|
let pending = queue.contents;
|
|
441
489
|
queue.contents = [];
|
|
442
490
|
pending.forEach(json => {
|
|
443
|
-
handler(json, undefined)
|
|
491
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
492
|
+
console.error("[LocalBus] parked command handler failed:", e);
|
|
493
|
+
return Promise.resolve();
|
|
494
|
+
});
|
|
444
495
|
});
|
|
445
496
|
};
|
|
446
497
|
let registerQueryDb = (name, ops) => {
|
|
@@ -455,6 +506,14 @@ function Make($star) {
|
|
|
455
506
|
queryDbStreamRegistry.contents[name] = streamFn;
|
|
456
507
|
};
|
|
457
508
|
let getQueryDbStream = name => queryDbStreamRegistry.contents[name];
|
|
509
|
+
let registerQueryDbIndexLookup = (name, lookup) => {
|
|
510
|
+
queryDbIndexLookupRegistry.contents[name] = lookup;
|
|
511
|
+
};
|
|
512
|
+
let getQueryDbIndexLookup = name => queryDbIndexLookupRegistry.contents[name];
|
|
513
|
+
let registerQueryDbListPage = (name, listPage) => {
|
|
514
|
+
queryDbListPageRegistry.contents[name] = listPage;
|
|
515
|
+
};
|
|
516
|
+
let getQueryDbListPage = name => queryDbListPageRegistry.contents[name];
|
|
458
517
|
let registerEventLogReplay = (name, replay) => {
|
|
459
518
|
eventLogReplayRegistry.contents[name] = replay;
|
|
460
519
|
};
|
|
@@ -480,7 +539,10 @@ function Make($star) {
|
|
|
480
539
|
contents: {}
|
|
481
540
|
};
|
|
482
541
|
let makeFireAndForgetHandler = handler => ((param, param$1, json) => {
|
|
483
|
-
handler(json, undefined)
|
|
542
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
543
|
+
console.error("[LocalBus] fire-and-forget handler failed:", e);
|
|
544
|
+
return Promise.resolve();
|
|
545
|
+
});
|
|
484
546
|
return Promise.resolve();
|
|
485
547
|
});
|
|
486
548
|
let registerEventCollectorHandler = (ecName, handler) => {
|
|
@@ -500,11 +562,18 @@ function Make($star) {
|
|
|
500
562
|
pending.push(topicName);
|
|
501
563
|
eventCollectorPendingTopics.contents[ecName] = pending;
|
|
502
564
|
};
|
|
565
|
+
let projectionCatchupRegistry = {
|
|
566
|
+
contents: {}
|
|
567
|
+
};
|
|
568
|
+
let registerProjectionCatchupHandler = (name, handler) => {
|
|
569
|
+
projectionCatchupRegistry.contents[name] = handler;
|
|
570
|
+
};
|
|
571
|
+
let projectionCatchupHandlers = () => Object.entries(projectionCatchupRegistry.contents);
|
|
503
572
|
let reset = () => {
|
|
504
|
-
let shutdownAll = Effect.map(Effect.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
573
|
+
let shutdownAll = Effect$1.map(Effect$1.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
505
574
|
concurrency: "unbounded"
|
|
506
575
|
}), param => {});
|
|
507
|
-
Effect.runSync(shutdownAll);
|
|
576
|
+
Effect$1.runSync(shutdownAll);
|
|
508
577
|
eventHubs.contents = {};
|
|
509
578
|
subscriberCounts.contents = {};
|
|
510
579
|
commandHandlers.contents = {};
|
|
@@ -512,11 +581,14 @@ function Make($star) {
|
|
|
512
581
|
queryDbRegistry.contents = {};
|
|
513
582
|
queryDbScanRegistry.contents = {};
|
|
514
583
|
queryDbStreamRegistry.contents = {};
|
|
584
|
+
queryDbIndexLookupRegistry.contents = {};
|
|
585
|
+
queryDbListPageRegistry.contents = {};
|
|
515
586
|
eventLogReplayRegistry.contents = {};
|
|
516
587
|
dcbEventLogReadRegistry.contents = {};
|
|
517
588
|
stateChangeListeners.contents = {};
|
|
518
589
|
eventCollectorHandlers.contents = {};
|
|
519
590
|
eventCollectorPendingTopics.contents = {};
|
|
591
|
+
projectionCatchupRegistry.contents = {};
|
|
520
592
|
};
|
|
521
593
|
return {
|
|
522
594
|
publishEvent: publishEvent,
|
|
@@ -530,6 +602,10 @@ function Make($star) {
|
|
|
530
602
|
getQueryDbScan: getQueryDbScan,
|
|
531
603
|
registerQueryDbStream: registerQueryDbStream,
|
|
532
604
|
getQueryDbStream: getQueryDbStream,
|
|
605
|
+
registerQueryDbIndexLookup: registerQueryDbIndexLookup,
|
|
606
|
+
getQueryDbIndexLookup: getQueryDbIndexLookup,
|
|
607
|
+
registerQueryDbListPage: registerQueryDbListPage,
|
|
608
|
+
getQueryDbListPage: getQueryDbListPage,
|
|
533
609
|
registerEventLogReplay: registerEventLogReplay,
|
|
534
610
|
getEventLogReplay: getEventLogReplay,
|
|
535
611
|
registerDcbEventLogRead: registerDcbEventLogRead,
|
|
@@ -538,6 +614,8 @@ function Make($star) {
|
|
|
538
614
|
subscribeToStateChanges: subscribeToStateChanges,
|
|
539
615
|
registerEventCollectorHandler: registerEventCollectorHandler,
|
|
540
616
|
subscribeEventCollectorToTopic: subscribeEventCollectorToTopic,
|
|
617
|
+
registerProjectionCatchupHandler: registerProjectionCatchupHandler,
|
|
618
|
+
projectionCatchupHandlers: projectionCatchupHandlers,
|
|
541
619
|
reset: reset
|
|
542
620
|
};
|
|
543
621
|
}
|
|
@@ -564,13 +642,19 @@ function MakeSilent($star) {
|
|
|
564
642
|
let queryDbStreamRegistry = {
|
|
565
643
|
contents: {}
|
|
566
644
|
};
|
|
645
|
+
let queryDbIndexLookupRegistry = {
|
|
646
|
+
contents: {}
|
|
647
|
+
};
|
|
648
|
+
let queryDbListPageRegistry = {
|
|
649
|
+
contents: {}
|
|
650
|
+
};
|
|
567
651
|
let eventLogReplayRegistry = {
|
|
568
652
|
contents: {}
|
|
569
653
|
};
|
|
570
654
|
let dcbEventLogReadRegistry = {
|
|
571
655
|
contents: {}
|
|
572
656
|
};
|
|
573
|
-
let makeHub = () => Effect.runSync(PubSub.unbounded());
|
|
657
|
+
let makeHub = () => Effect$1.runSync(PubSub.unbounded());
|
|
574
658
|
let subscribeToEvents = (topicName, handler) => {
|
|
575
659
|
let h = eventHubs.contents[topicName];
|
|
576
660
|
let hub;
|
|
@@ -583,8 +667,10 @@ function MakeSilent($star) {
|
|
|
583
667
|
}
|
|
584
668
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
585
669
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
586
|
-
let drainLoop = Effect.scoped(Effect.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect.
|
|
587
|
-
|
|
670
|
+
let drainLoop = Effect$1.scoped(Effect$1.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect$1.ensuring(Effect$1.catchAll(Effect.tryPromise(e => e, () => handler(msg.service, msg.meta, msg.json)), err => Effect$1.sync(() => {
|
|
671
|
+
console.error("[LocalBus] subscriber handler failed:", err);
|
|
672
|
+
})), msg.done_))));
|
|
673
|
+
Effect$1.runFork(drainLoop);
|
|
588
674
|
};
|
|
589
675
|
let subscribeToEventStream = topicName => {
|
|
590
676
|
let h = eventHubs.contents[topicName];
|
|
@@ -596,10 +682,10 @@ function MakeSilent($star) {
|
|
|
596
682
|
eventHubs.contents[topicName] = h$1;
|
|
597
683
|
hub = h$1;
|
|
598
684
|
}
|
|
599
|
-
return Effect.map(Effect.acquireRelease(Effect.flatMap(Effect.sync(() => {
|
|
685
|
+
return Effect$1.map(Effect$1.acquireRelease(Effect$1.flatMap(Effect$1.sync(() => {
|
|
600
686
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
601
687
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
602
|
-
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect.zipRight(Effect.sync(() => {
|
|
688
|
+
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect$1.zipRight(Effect$1.sync(() => {
|
|
603
689
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 1);
|
|
604
690
|
subscriberCounts.contents[topicName] = n - 1 | 0;
|
|
605
691
|
}), Queue.shutdown(queue))), queue => Stream.fromQueue(queue));
|
|
@@ -617,17 +703,17 @@ function MakeSilent($star) {
|
|
|
617
703
|
if (n === 0) {
|
|
618
704
|
return;
|
|
619
705
|
}
|
|
620
|
-
let allDone = Effect.runSync(Deferred.make());
|
|
706
|
+
let allDone = Effect$1.runSync(Deferred.make());
|
|
621
707
|
let remaining = {
|
|
622
708
|
contents: n
|
|
623
709
|
};
|
|
624
|
-
let done_ = Effect.flatMap(Effect.sync(() => {
|
|
710
|
+
let done_ = Effect$1.flatMap(Effect$1.sync(() => {
|
|
625
711
|
remaining.contents = remaining.contents - 1 | 0;
|
|
626
712
|
}), () => {
|
|
627
713
|
if (remaining.contents === 0) {
|
|
628
|
-
return Effect.map(Deferred.succeed(allDone, undefined), param => {});
|
|
714
|
+
return Effect$1.map(Deferred.succeed(allDone, undefined), param => {});
|
|
629
715
|
} else {
|
|
630
|
-
return Effect.succeed();
|
|
716
|
+
return Effect$1.succeed();
|
|
631
717
|
}
|
|
632
718
|
});
|
|
633
719
|
let msg = {
|
|
@@ -636,10 +722,10 @@ function MakeSilent($star) {
|
|
|
636
722
|
json: json,
|
|
637
723
|
done_: done_
|
|
638
724
|
};
|
|
639
|
-
let publishAndWait = Effect.zipRight(Effect.sync(() => {
|
|
640
|
-
Effect.runSync(PubSub.publish(hub$1, msg));
|
|
725
|
+
let publishAndWait = Effect$1.zipRight(Effect$1.sync(() => {
|
|
726
|
+
Effect$1.runSync(PubSub.publish(hub$1, msg));
|
|
641
727
|
}), Deferred.await(allDone));
|
|
642
|
-
await Effect.runPromise(publishAndWait);
|
|
728
|
+
await Effect$1.runPromise(publishAndWait);
|
|
643
729
|
};
|
|
644
730
|
let dispatchCommand = async (channelName, json) => {
|
|
645
731
|
let handler = commandHandlers.contents[channelName];
|
|
@@ -668,7 +754,10 @@ function MakeSilent($star) {
|
|
|
668
754
|
let pending = queue.contents;
|
|
669
755
|
queue.contents = [];
|
|
670
756
|
pending.forEach(json => {
|
|
671
|
-
handler(json, undefined)
|
|
757
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
758
|
+
console.error("[LocalBus] parked command handler failed:", e);
|
|
759
|
+
return Promise.resolve();
|
|
760
|
+
});
|
|
672
761
|
});
|
|
673
762
|
};
|
|
674
763
|
let registerQueryDb = (name, ops) => {
|
|
@@ -683,6 +772,14 @@ function MakeSilent($star) {
|
|
|
683
772
|
queryDbStreamRegistry.contents[name] = streamFn;
|
|
684
773
|
};
|
|
685
774
|
let getQueryDbStream = name => queryDbStreamRegistry.contents[name];
|
|
775
|
+
let registerQueryDbIndexLookup = (name, lookup) => {
|
|
776
|
+
queryDbIndexLookupRegistry.contents[name] = lookup;
|
|
777
|
+
};
|
|
778
|
+
let getQueryDbIndexLookup = name => queryDbIndexLookupRegistry.contents[name];
|
|
779
|
+
let registerQueryDbListPage = (name, listPage) => {
|
|
780
|
+
queryDbListPageRegistry.contents[name] = listPage;
|
|
781
|
+
};
|
|
782
|
+
let getQueryDbListPage = name => queryDbListPageRegistry.contents[name];
|
|
686
783
|
let registerEventLogReplay = (name, replay) => {
|
|
687
784
|
eventLogReplayRegistry.contents[name] = replay;
|
|
688
785
|
};
|
|
@@ -708,7 +805,10 @@ function MakeSilent($star) {
|
|
|
708
805
|
contents: {}
|
|
709
806
|
};
|
|
710
807
|
let makeFireAndForgetHandler = handler => ((param, param$1, json) => {
|
|
711
|
-
handler(json, undefined)
|
|
808
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
809
|
+
console.error("[LocalBus] fire-and-forget handler failed:", e);
|
|
810
|
+
return Promise.resolve();
|
|
811
|
+
});
|
|
712
812
|
return Promise.resolve();
|
|
713
813
|
});
|
|
714
814
|
let registerEventCollectorHandler = (ecName, handler) => {
|
|
@@ -728,11 +828,18 @@ function MakeSilent($star) {
|
|
|
728
828
|
pending.push(topicName);
|
|
729
829
|
eventCollectorPendingTopics.contents[ecName] = pending;
|
|
730
830
|
};
|
|
831
|
+
let projectionCatchupRegistry = {
|
|
832
|
+
contents: {}
|
|
833
|
+
};
|
|
834
|
+
let registerProjectionCatchupHandler = (name, handler) => {
|
|
835
|
+
projectionCatchupRegistry.contents[name] = handler;
|
|
836
|
+
};
|
|
837
|
+
let projectionCatchupHandlers = () => Object.entries(projectionCatchupRegistry.contents);
|
|
731
838
|
let reset = () => {
|
|
732
|
-
let shutdownAll = Effect.map(Effect.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
839
|
+
let shutdownAll = Effect$1.map(Effect$1.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
733
840
|
concurrency: "unbounded"
|
|
734
841
|
}), param => {});
|
|
735
|
-
Effect.runSync(shutdownAll);
|
|
842
|
+
Effect$1.runSync(shutdownAll);
|
|
736
843
|
eventHubs.contents = {};
|
|
737
844
|
subscriberCounts.contents = {};
|
|
738
845
|
commandHandlers.contents = {};
|
|
@@ -740,11 +847,14 @@ function MakeSilent($star) {
|
|
|
740
847
|
queryDbRegistry.contents = {};
|
|
741
848
|
queryDbScanRegistry.contents = {};
|
|
742
849
|
queryDbStreamRegistry.contents = {};
|
|
850
|
+
queryDbIndexLookupRegistry.contents = {};
|
|
851
|
+
queryDbListPageRegistry.contents = {};
|
|
743
852
|
eventLogReplayRegistry.contents = {};
|
|
744
853
|
dcbEventLogReadRegistry.contents = {};
|
|
745
854
|
stateChangeListeners.contents = {};
|
|
746
855
|
eventCollectorHandlers.contents = {};
|
|
747
856
|
eventCollectorPendingTopics.contents = {};
|
|
857
|
+
projectionCatchupRegistry.contents = {};
|
|
748
858
|
};
|
|
749
859
|
return {
|
|
750
860
|
publishEvent: publishEvent,
|
|
@@ -758,6 +868,10 @@ function MakeSilent($star) {
|
|
|
758
868
|
getQueryDbScan: getQueryDbScan,
|
|
759
869
|
registerQueryDbStream: registerQueryDbStream,
|
|
760
870
|
getQueryDbStream: getQueryDbStream,
|
|
871
|
+
registerQueryDbIndexLookup: registerQueryDbIndexLookup,
|
|
872
|
+
getQueryDbIndexLookup: getQueryDbIndexLookup,
|
|
873
|
+
registerQueryDbListPage: registerQueryDbListPage,
|
|
874
|
+
getQueryDbListPage: getQueryDbListPage,
|
|
761
875
|
registerEventLogReplay: registerEventLogReplay,
|
|
762
876
|
getEventLogReplay: getEventLogReplay,
|
|
763
877
|
registerDcbEventLogRead: registerDcbEventLogRead,
|
|
@@ -766,6 +880,8 @@ function MakeSilent($star) {
|
|
|
766
880
|
subscribeToStateChanges: subscribeToStateChanges,
|
|
767
881
|
registerEventCollectorHandler: registerEventCollectorHandler,
|
|
768
882
|
subscribeEventCollectorToTopic: subscribeEventCollectorToTopic,
|
|
883
|
+
registerProjectionCatchupHandler: registerProjectionCatchupHandler,
|
|
884
|
+
projectionCatchupHandlers: projectionCatchupHandlers,
|
|
769
885
|
reset: reset
|
|
770
886
|
};
|
|
771
887
|
}
|
|
@@ -793,13 +909,19 @@ function MakeBounded(C) {
|
|
|
793
909
|
let queryDbStreamRegistry = {
|
|
794
910
|
contents: {}
|
|
795
911
|
};
|
|
912
|
+
let queryDbIndexLookupRegistry = {
|
|
913
|
+
contents: {}
|
|
914
|
+
};
|
|
915
|
+
let queryDbListPageRegistry = {
|
|
916
|
+
contents: {}
|
|
917
|
+
};
|
|
796
918
|
let eventLogReplayRegistry = {
|
|
797
919
|
contents: {}
|
|
798
920
|
};
|
|
799
921
|
let dcbEventLogReadRegistry = {
|
|
800
922
|
contents: {}
|
|
801
923
|
};
|
|
802
|
-
let makeHub = () => Effect.runSync(PubSub.bounded(capacity));
|
|
924
|
+
let makeHub = () => Effect$1.runSync(PubSub.bounded(capacity));
|
|
803
925
|
let subscribeToEvents = (topicName, handler) => {
|
|
804
926
|
let h = eventHubs.contents[topicName];
|
|
805
927
|
let hub;
|
|
@@ -812,8 +934,10 @@ function MakeBounded(C) {
|
|
|
812
934
|
}
|
|
813
935
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
814
936
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
815
|
-
let drainLoop = Effect.scoped(Effect.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect.
|
|
816
|
-
|
|
937
|
+
let drainLoop = Effect$1.scoped(Effect$1.flatMap(PubSub.subscribe(hub), queue => Stream.runForEach(Stream.fromQueue(queue), msg => Effect$1.ensuring(Effect$1.catchAll(Effect.tryPromise(e => e, () => handler(msg.service, msg.meta, msg.json)), err => Effect$1.sync(() => {
|
|
938
|
+
console.error("[LocalBus] subscriber handler failed:", err);
|
|
939
|
+
})), msg.done_))));
|
|
940
|
+
Effect$1.runFork(drainLoop);
|
|
817
941
|
};
|
|
818
942
|
let subscribeToEventStream = topicName => {
|
|
819
943
|
let h = eventHubs.contents[topicName];
|
|
@@ -825,10 +949,10 @@ function MakeBounded(C) {
|
|
|
825
949
|
eventHubs.contents[topicName] = h$1;
|
|
826
950
|
hub = h$1;
|
|
827
951
|
}
|
|
828
|
-
return Effect.map(Effect.acquireRelease(Effect.flatMap(Effect.sync(() => {
|
|
952
|
+
return Effect$1.map(Effect$1.acquireRelease(Effect$1.flatMap(Effect$1.sync(() => {
|
|
829
953
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 0);
|
|
830
954
|
subscriberCounts.contents[topicName] = n + 1 | 0;
|
|
831
|
-
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect.zipRight(Effect.sync(() => {
|
|
955
|
+
}), () => PubSub.subscribe(hub)), (queue, _exit) => Effect$1.zipRight(Effect$1.sync(() => {
|
|
832
956
|
let n = Stdlib_Option.getOr(subscriberCounts.contents[topicName], 1);
|
|
833
957
|
subscriberCounts.contents[topicName] = n - 1 | 0;
|
|
834
958
|
}), Queue.shutdown(queue))), queue => Stream.fromQueue(queue));
|
|
@@ -845,17 +969,17 @@ function MakeBounded(C) {
|
|
|
845
969
|
if (n === 0) {
|
|
846
970
|
return;
|
|
847
971
|
}
|
|
848
|
-
let allDone = Effect.runSync(Deferred.make());
|
|
972
|
+
let allDone = Effect$1.runSync(Deferred.make());
|
|
849
973
|
let remaining = {
|
|
850
974
|
contents: n
|
|
851
975
|
};
|
|
852
|
-
let done_ = Effect.flatMap(Effect.sync(() => {
|
|
976
|
+
let done_ = Effect$1.flatMap(Effect$1.sync(() => {
|
|
853
977
|
remaining.contents = remaining.contents - 1 | 0;
|
|
854
978
|
}), () => {
|
|
855
979
|
if (remaining.contents === 0) {
|
|
856
|
-
return Effect.map(Deferred.succeed(allDone, undefined), param => {});
|
|
980
|
+
return Effect$1.map(Deferred.succeed(allDone, undefined), param => {});
|
|
857
981
|
} else {
|
|
858
|
-
return Effect.succeed();
|
|
982
|
+
return Effect$1.succeed();
|
|
859
983
|
}
|
|
860
984
|
});
|
|
861
985
|
let msg = {
|
|
@@ -864,8 +988,8 @@ function MakeBounded(C) {
|
|
|
864
988
|
json: json,
|
|
865
989
|
done_: done_
|
|
866
990
|
};
|
|
867
|
-
let publishAndWait = Effect.flatMap(PubSub.publish(Primitive_option.valFromOption(hub), msg), param => Deferred.await(allDone));
|
|
868
|
-
await Effect.runPromise(publishAndWait);
|
|
991
|
+
let publishAndWait = Effect$1.flatMap(PubSub.publish(Primitive_option.valFromOption(hub), msg), param => Deferred.await(allDone));
|
|
992
|
+
await Effect$1.runPromise(publishAndWait);
|
|
869
993
|
};
|
|
870
994
|
let dispatchCommand = async (channelName, json) => {
|
|
871
995
|
let handler = commandHandlers.contents[channelName];
|
|
@@ -894,7 +1018,10 @@ function MakeBounded(C) {
|
|
|
894
1018
|
let pending = queue.contents;
|
|
895
1019
|
queue.contents = [];
|
|
896
1020
|
pending.forEach(json => {
|
|
897
|
-
handler(json, undefined)
|
|
1021
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
1022
|
+
console.error("[LocalBus] parked command handler failed:", e);
|
|
1023
|
+
return Promise.resolve();
|
|
1024
|
+
});
|
|
898
1025
|
});
|
|
899
1026
|
};
|
|
900
1027
|
let registerQueryDb = (name, ops) => {
|
|
@@ -909,6 +1036,14 @@ function MakeBounded(C) {
|
|
|
909
1036
|
queryDbStreamRegistry.contents[name] = streamFn;
|
|
910
1037
|
};
|
|
911
1038
|
let getQueryDbStream = name => queryDbStreamRegistry.contents[name];
|
|
1039
|
+
let registerQueryDbIndexLookup = (name, lookup) => {
|
|
1040
|
+
queryDbIndexLookupRegistry.contents[name] = lookup;
|
|
1041
|
+
};
|
|
1042
|
+
let getQueryDbIndexLookup = name => queryDbIndexLookupRegistry.contents[name];
|
|
1043
|
+
let registerQueryDbListPage = (name, listPage) => {
|
|
1044
|
+
queryDbListPageRegistry.contents[name] = listPage;
|
|
1045
|
+
};
|
|
1046
|
+
let getQueryDbListPage = name => queryDbListPageRegistry.contents[name];
|
|
912
1047
|
let registerEventLogReplay = (name, replay) => {
|
|
913
1048
|
eventLogReplayRegistry.contents[name] = replay;
|
|
914
1049
|
};
|
|
@@ -934,7 +1069,10 @@ function MakeBounded(C) {
|
|
|
934
1069
|
contents: {}
|
|
935
1070
|
};
|
|
936
1071
|
let makeFireAndForgetHandler = handler => ((param, param$1, json) => {
|
|
937
|
-
handler(json, undefined)
|
|
1072
|
+
Stdlib_Promise.$$catch(handler(json, undefined), e => {
|
|
1073
|
+
console.error("[LocalBus] fire-and-forget handler failed:", e);
|
|
1074
|
+
return Promise.resolve();
|
|
1075
|
+
});
|
|
938
1076
|
return Promise.resolve();
|
|
939
1077
|
});
|
|
940
1078
|
let registerEventCollectorHandler = (ecName, handler) => {
|
|
@@ -954,11 +1092,18 @@ function MakeBounded(C) {
|
|
|
954
1092
|
pending.push(topicName);
|
|
955
1093
|
eventCollectorPendingTopics.contents[ecName] = pending;
|
|
956
1094
|
};
|
|
1095
|
+
let projectionCatchupRegistry = {
|
|
1096
|
+
contents: {}
|
|
1097
|
+
};
|
|
1098
|
+
let registerProjectionCatchupHandler = (name, handler) => {
|
|
1099
|
+
projectionCatchupRegistry.contents[name] = handler;
|
|
1100
|
+
};
|
|
1101
|
+
let projectionCatchupHandlers = () => Object.entries(projectionCatchupRegistry.contents);
|
|
957
1102
|
let reset = () => {
|
|
958
|
-
let shutdownAll = Effect.map(Effect.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
1103
|
+
let shutdownAll = Effect$1.map(Effect$1.all(Object.values(eventHubs.contents).map(hub => PubSub.shutdown(hub)), {
|
|
959
1104
|
concurrency: "unbounded"
|
|
960
1105
|
}), param => {});
|
|
961
|
-
Effect.runSync(shutdownAll);
|
|
1106
|
+
Effect$1.runSync(shutdownAll);
|
|
962
1107
|
eventHubs.contents = {};
|
|
963
1108
|
subscriberCounts.contents = {};
|
|
964
1109
|
commandHandlers.contents = {};
|
|
@@ -966,11 +1111,14 @@ function MakeBounded(C) {
|
|
|
966
1111
|
queryDbRegistry.contents = {};
|
|
967
1112
|
queryDbScanRegistry.contents = {};
|
|
968
1113
|
queryDbStreamRegistry.contents = {};
|
|
1114
|
+
queryDbIndexLookupRegistry.contents = {};
|
|
1115
|
+
queryDbListPageRegistry.contents = {};
|
|
969
1116
|
eventLogReplayRegistry.contents = {};
|
|
970
1117
|
dcbEventLogReadRegistry.contents = {};
|
|
971
1118
|
stateChangeListeners.contents = {};
|
|
972
1119
|
eventCollectorHandlers.contents = {};
|
|
973
1120
|
eventCollectorPendingTopics.contents = {};
|
|
1121
|
+
projectionCatchupRegistry.contents = {};
|
|
974
1122
|
};
|
|
975
1123
|
return {
|
|
976
1124
|
publishEvent: publishEvent,
|
|
@@ -984,6 +1132,10 @@ function MakeBounded(C) {
|
|
|
984
1132
|
getQueryDbScan: getQueryDbScan,
|
|
985
1133
|
registerQueryDbStream: registerQueryDbStream,
|
|
986
1134
|
getQueryDbStream: getQueryDbStream,
|
|
1135
|
+
registerQueryDbIndexLookup: registerQueryDbIndexLookup,
|
|
1136
|
+
getQueryDbIndexLookup: getQueryDbIndexLookup,
|
|
1137
|
+
registerQueryDbListPage: registerQueryDbListPage,
|
|
1138
|
+
getQueryDbListPage: getQueryDbListPage,
|
|
987
1139
|
registerEventLogReplay: registerEventLogReplay,
|
|
988
1140
|
getEventLogReplay: getEventLogReplay,
|
|
989
1141
|
registerDcbEventLogRead: registerDcbEventLogRead,
|
|
@@ -992,6 +1144,8 @@ function MakeBounded(C) {
|
|
|
992
1144
|
subscribeToStateChanges: subscribeToStateChanges,
|
|
993
1145
|
registerEventCollectorHandler: registerEventCollectorHandler,
|
|
994
1146
|
subscribeEventCollectorToTopic: subscribeEventCollectorToTopic,
|
|
1147
|
+
registerProjectionCatchupHandler: registerProjectionCatchupHandler,
|
|
1148
|
+
projectionCatchupHandlers: projectionCatchupHandlers,
|
|
995
1149
|
reset: reset
|
|
996
1150
|
};
|
|
997
1151
|
}
|
|
@@ -1008,4 +1162,4 @@ export {
|
|
|
1008
1162
|
MakeSilent,
|
|
1009
1163
|
MakeBounded,
|
|
1010
1164
|
}
|
|
1011
|
-
/*
|
|
1165
|
+
/* Effect Not a pure module */
|