@reventlessdev/reventless-core 3.0.0-alpha.310 → 3.0.0-alpha.311
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 +20 -0
- package/package.json +5 -5
- package/src/Message.res +9 -2
- package/src/Message.res.mjs +8 -1
- package/src/admin/Platform_Admin.res.mjs +0 -2
- package/src/components/Aggregate/Aggregate_Callback.res +111 -48
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +107 -49
- package/src/components/Builder_Helpers.res +0 -17
- package/src/components/Builder_Helpers.res.mjs +0 -15
- package/src/components/EventLog/EventLog.res +7 -0
- package/src/components/EventLog/EventLog_Builder.res +2 -0
- package/src/components/EventLog/EventLog_Builder.res.mjs +1 -0
- package/src/components/EventLog/EventLog_Operations.res +30 -0
- package/src/components/EventLog/EventLog_Operations.res.mjs +18 -0
- package/src/components/Extension/Extension.res +0 -2
- package/src/components/Extension/Extension_Builder.res +2 -20
- package/src/components/Extension/Extension_Builder.res.mjs +1 -3
- package/src/components/Extension/Extension_Operations.res +0 -19
- package/src/components/Extension/Extension_Operations.res.mjs +1 -7
- package/src/components/ReadModel/ReadModel_Builder.res +12 -2
- package/src/components/ReadModel/ReadModel_Builder.res.mjs +2 -1
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +72 -35
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +45 -31
- package/src/plugin/component/Plugin_Builder.res +1 -26
- package/src/plugin/component/Plugin_Builder.res.mjs +6 -20
- package/src/plugin/component/Plugin_Helpers.res +0 -37
- package/src/plugin/component/Plugin_Helpers.res.mjs +8 -21
- package/tests/aggregate/AggregateCacheTest.res +6 -0
- package/tests/aggregate/AggregateCacheTest.res.mjs +5 -0
- package/tests/aggregate/AggregateConflictTest.res +6 -0
- package/tests/aggregate/AggregateConflictTest.res.mjs +5 -0
- package/tests/aggregate/AggregateFixtures.res +6 -0
- package/tests/aggregate/AggregateFixtures.res.mjs +5 -0
- package/tests/aggregate/AggregateRepeatTest.res +186 -0
- package/tests/aggregate/AggregateRepeatTest.res.mjs +332 -0
- package/tests/aggregate/AggregateSnapshotTest.res +6 -0
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +12 -0
- package/tests/commandgenerator/OwnerActingTest.res +6 -0
- package/tests/commandgenerator/OwnerActingTest.res.mjs +5 -0
- package/tests/extensionpoint/DerivedMessageIdTest.res +217 -0
- package/tests/extensionpoint/DerivedMessageIdTest.res.mjs +361 -0
- package/tests/logger/LogFormatTest.res +1 -2
- package/tests/logger/LogFormatTest.res.mjs +2 -3
- package/tests/message/MessageTest.res +48 -1
- package/tests/message/MessageTest.res.mjs +56 -2
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +0 -1
|
@@ -650,11 +650,10 @@ module Make = (
|
|
|
650
650
|
(interstackAdminExtensionPoints, localAdminResolvedEP, schemaPushed)->Pulumi.Output.all3,
|
|
651
651
|
aggregateResources->Pulumi.Output.allDict,
|
|
652
652
|
publishToAggregates->Pulumi.Output.allDict,
|
|
653
|
-
publishToReadModels->Pulumi.Output.allDict,
|
|
654
653
|
scheduler,
|
|
655
654
|
queryEngine,
|
|
656
655
|
)
|
|
657
|
-
->Pulumi.Output.
|
|
656
|
+
->Pulumi.Output.all5
|
|
658
657
|
// `applyAttributed`, not `apply`: this callback provisions real resources —
|
|
659
658
|
// extension points, tasks, the heartbeat, resolvers — and it runs after
|
|
660
659
|
// this construct has returned, when the ambient attribution context is
|
|
@@ -663,7 +662,6 @@ module Make = (
|
|
|
663
662
|
(interstackAdminExtensionPoints, localAdminResolvedEP, _),
|
|
664
663
|
aggregateResources,
|
|
665
664
|
publishToAggregates,
|
|
666
|
-
publishToReadModels,
|
|
667
665
|
scheduler,
|
|
668
666
|
queryEngine,
|
|
669
667
|
)) => {
|
|
@@ -717,7 +715,6 @@ module Make = (
|
|
|
717
715
|
~pluginName=name,
|
|
718
716
|
~publishToPluginExtensionPoint,
|
|
719
717
|
~publishToAggregates,
|
|
720
|
-
~publishToReadModels,
|
|
721
718
|
~queryEngine,
|
|
722
719
|
~opts,
|
|
723
720
|
)
|
|
@@ -851,22 +848,6 @@ module Make = (
|
|
|
851
848
|
aggregateQueueUrls->Dict.set(Sc.Spec.name, dcbResult.dcbCommandTopicQueueUrl)
|
|
852
849
|
)
|
|
853
850
|
|
|
854
|
-
// Per-RM EventCollector SQS URL — populated only for plugins that
|
|
855
|
-
// expose RMs the bundled handler may enqueue events into directly.
|
|
856
|
-
let readModelQueueUrls: dict<Pulumi.Output.t<string>> = Dict.make()
|
|
857
|
-
readModelsOutputs
|
|
858
|
-
->Dict.toArray
|
|
859
|
-
->Array.forEach(((rmName, rmOut)) => {
|
|
860
|
-
let urlOutput = rmOut.eventCollector->Pulumi.Output.flatMap(
|
|
861
|
-
ecOutputs =>
|
|
862
|
-
switch ecOutputs.resources->Array.get(0) {
|
|
863
|
-
| Some(r) => r.id
|
|
864
|
-
| None => Pulumi.Output.make("")
|
|
865
|
-
},
|
|
866
|
-
)
|
|
867
|
-
readModelQueueUrls->Dict.set(rmName, urlOutput)
|
|
868
|
-
})
|
|
869
|
-
|
|
870
851
|
switch coreSetup {
|
|
871
852
|
| Some((pluginExtensionPointUnwrapped, _)) => {
|
|
872
853
|
let (
|
|
@@ -877,8 +858,6 @@ module Make = (
|
|
|
877
858
|
~uiFragments,
|
|
878
859
|
~publishToPluginExtensionPoint,
|
|
879
860
|
~publishToAggregates,
|
|
880
|
-
~readModelNamesForSourceName,
|
|
881
|
-
~publishToReadModels,
|
|
882
861
|
~queryEngine,
|
|
883
862
|
~opts,
|
|
884
863
|
)
|
|
@@ -897,8 +876,6 @@ module Make = (
|
|
|
897
876
|
~extensionRegistryInfos,
|
|
898
877
|
~extensionPointRegistryInfos,
|
|
899
878
|
~aggregateQueueUrls,
|
|
900
|
-
~readModelQueueUrls,
|
|
901
|
-
~readModelNamesForSourceName,
|
|
902
879
|
)
|
|
903
880
|
}
|
|
904
881
|
| None =>
|
|
@@ -914,8 +891,6 @@ module Make = (
|
|
|
914
891
|
~extensionPointsHandlers,
|
|
915
892
|
~extensionRegistryInfos,
|
|
916
893
|
~aggregateQueueUrls,
|
|
917
|
-
~readModelQueueUrls,
|
|
918
|
-
~readModelNamesForSourceName,
|
|
919
894
|
)
|
|
920
895
|
}
|
|
921
896
|
|
|
@@ -443,13 +443,11 @@ function Make(Spec) {
|
|
|
443
443
|
]),
|
|
444
444
|
Pulumi.all(Plugin_Helpers$ReventlessCore.aggregateResources),
|
|
445
445
|
Pulumi.all(Plugin_Helpers$ReventlessCore.publishToAggregates),
|
|
446
|
-
Pulumi.all(Plugin_Helpers$ReventlessCore.publishToReadModels),
|
|
447
446
|
scheduler,
|
|
448
447
|
queryEngine
|
|
449
448
|
]), param => {
|
|
450
|
-
let queryEngine = param[
|
|
451
|
-
let scheduler = param[
|
|
452
|
-
let publishToReadModels = param[3];
|
|
449
|
+
let queryEngine = param[4];
|
|
450
|
+
let scheduler = param[3];
|
|
453
451
|
let publishToAggregates = param[2];
|
|
454
452
|
let aggregateResources = param[1];
|
|
455
453
|
let match = param[0];
|
|
@@ -477,7 +475,7 @@ function Make(Spec) {
|
|
|
477
475
|
coreSetup = undefined;
|
|
478
476
|
}
|
|
479
477
|
let publishToPluginExtensionPoint = coreSetup !== undefined ? coreSetup[1].remotePublish : async param => {};
|
|
480
|
-
let match$2 = Plugin_Helpers$ReventlessCore.createExtensions(extensions, extra$1, publishToPluginExtensionPoint, publishToAggregates,
|
|
478
|
+
let match$2 = Plugin_Helpers$ReventlessCore.createExtensions(extensions, extra$1, publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts);
|
|
481
479
|
let extensionRegistryInfos = match$2[2];
|
|
482
480
|
let extensionsHandlers = match$2[1];
|
|
483
481
|
let extensionsOutputs = match$2[0];
|
|
@@ -541,23 +539,11 @@ function Make(Spec) {
|
|
|
541
539
|
stateChangeSlices.forEach(Sc => {
|
|
542
540
|
aggregateQueueUrls[Sc.Spec.name] = dcbResult.dcbCommandTopicQueueUrl;
|
|
543
541
|
});
|
|
544
|
-
let readModelQueueUrls = {};
|
|
545
|
-
Object.entries(readModelsOutputs).forEach(param => {
|
|
546
|
-
let urlOutput = Output$Pulumi.flatMap(param[1].eventCollector, ecOutputs => {
|
|
547
|
-
let r = ecOutputs.resources[0];
|
|
548
|
-
if (r !== undefined) {
|
|
549
|
-
return r.id;
|
|
550
|
-
} else {
|
|
551
|
-
return Pulumi.output("");
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
readModelQueueUrls[param[0]] = urlOutput;
|
|
555
|
-
});
|
|
556
542
|
if (coreSetup !== undefined) {
|
|
557
|
-
let match$4 = Plugin_Helpers$ReventlessCore.createConnectPluginExtension(pluginDefinition, uiFragments, publishToPluginExtensionPoint, publishToAggregates,
|
|
558
|
-
EventCollectorHelper.connect(eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, coreSetup[0], pluginDefinition, Primitive_option.some(uiFragments), match$4[1], extensionsHandlers, extensionPointsHandlers, match$4[0], extensionRegistryInfos, match$1[2], aggregateQueueUrls
|
|
543
|
+
let match$4 = Plugin_Helpers$ReventlessCore.createConnectPluginExtension(pluginDefinition, uiFragments, publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts);
|
|
544
|
+
EventCollectorHelper.connect(eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, coreSetup[0], pluginDefinition, Primitive_option.some(uiFragments), match$4[1], extensionsHandlers, extensionPointsHandlers, match$4[0], extensionRegistryInfos, match$1[2], aggregateQueueUrls);
|
|
559
545
|
} else {
|
|
560
|
-
EventCollectorHelper.connect(eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, undefined, pluginDefinition, Primitive_option.some(uiFragments), undefined, extensionsHandlers, extensionPointsHandlers, undefined, extensionRegistryInfos, undefined, aggregateQueueUrls
|
|
546
|
+
EventCollectorHelper.connect(eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, undefined, pluginDefinition, Primitive_option.some(uiFragments), undefined, extensionsHandlers, extensionPointsHandlers, undefined, extensionRegistryInfos, undefined, aggregateQueueUrls);
|
|
561
547
|
}
|
|
562
548
|
let tasksOutputs = Plugin_Helpers$ReventlessCore.createTasks(tasks, aggregatesOutputs, scheduler, schedulerRoleUrn, publishToAggregates, queryEngine, Spec.resourceNaming, componentRuntime, opts);
|
|
563
549
|
let resolvers = Plugin_Helpers$ReventlessCore.createResolvers(allQueryDbs);
|
|
@@ -136,10 +136,6 @@ type extensionEntry = {
|
|
|
136
136
|
// Subset of top-level publishToAggregates this extension publishes to —
|
|
137
137
|
// derived from Extension.outputs.aggregateNames.
|
|
138
138
|
aggregateNames: array<string>,
|
|
139
|
-
// RMs this extension's mapping may enqueue events into directly. Derived
|
|
140
|
-
// from readModelNamesForSourceName by reverse lookup on the extension's
|
|
141
|
-
// EP name (the source carried on incoming events).
|
|
142
|
-
readModelNames: array<string>,
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
type eventCollectorContext = {
|
|
@@ -169,12 +165,6 @@ type eventCollectorContext = {
|
|
|
169
165
|
// any user extension publishes to plus the admin's Plugin aggregate when
|
|
170
166
|
// ConnectExtension is wired.
|
|
171
167
|
publishToAggregates: dict<Pulumi.Output.t<string>>,
|
|
172
|
-
// rmName → RM EventCollector SQS URL. Populated only for RMs that user
|
|
173
|
-
// extensions feed directly via Extension_Operations.publishToReadModels.
|
|
174
|
-
readModelQueueUrls: dict<Pulumi.Output.t<string>>,
|
|
175
|
-
// Inversion of RM.sourceNames — sourceServiceName → [rmName]. Same dict
|
|
176
|
-
// surface used by Builder_Helpers; serialised verbatim into HANDLER_CONFIG.
|
|
177
|
-
readModelNamesForSourceName: dict<array<string>>,
|
|
178
168
|
}
|
|
179
169
|
|
|
180
170
|
let eventCollectorContextRef: ref<dict<eventCollectorContext>> = ref(Dict.make())
|
|
@@ -254,7 +244,6 @@ let createExtensions = (
|
|
|
254
244
|
~pluginName,
|
|
255
245
|
~publishToPluginExtensionPoint,
|
|
256
246
|
~publishToAggregates,
|
|
257
|
-
~publishToReadModels,
|
|
258
247
|
~queryEngine,
|
|
259
248
|
~opts,
|
|
260
249
|
) => {
|
|
@@ -297,8 +286,6 @@ let createExtensions = (
|
|
|
297
286
|
let extension = ExtensionMaker.make(
|
|
298
287
|
~publishToPluginExtensionPoint,
|
|
299
288
|
~publishToAggregates,
|
|
300
|
-
~readModelNamesForSourceName,
|
|
301
|
-
~publishToReadModels,
|
|
302
289
|
~queryEngine,
|
|
303
290
|
~opts=Some(opts),
|
|
304
291
|
)
|
|
@@ -359,15 +346,10 @@ let extractExtensionPointDefinitions = (extensionPointsOutputs: array<ExtensionP
|
|
|
359
346
|
)
|
|
360
347
|
->Pulumi.Output.all
|
|
361
348
|
|
|
362
|
-
// `dcbSources` lists cross-plugin DCB EventLog names this extension consumes.
|
|
363
|
-
// Empty for now: the current Extension model is mono-source (single EP Spec).
|
|
364
|
-
// Future work will populate this by walking extension blueprint mappings for
|
|
365
|
-
// `Source { name = "<peer>DcbEventLog" }` declarations.
|
|
366
349
|
let extractExtensionDefinitions = (extensionsOutputs: array<Extension.outputs>) =>
|
|
367
350
|
extensionsOutputs->Array.map(extensionOutputs => {
|
|
368
351
|
Reventless.Plugin.name: extensionOutputs.name,
|
|
369
352
|
extensionPointName: extensionOutputs.extensionPointName,
|
|
370
|
-
dcbSources: [],
|
|
371
353
|
})
|
|
372
354
|
|
|
373
355
|
let createConnectPluginExtension = (
|
|
@@ -375,8 +357,6 @@ let createConnectPluginExtension = (
|
|
|
375
357
|
~uiFragments: option<Reventless.Plugin.uiFragmentManifest>,
|
|
376
358
|
~publishToPluginExtensionPoint,
|
|
377
359
|
~publishToAggregates,
|
|
378
|
-
~readModelNamesForSourceName,
|
|
379
|
-
~publishToReadModels,
|
|
380
360
|
~queryEngine,
|
|
381
361
|
~opts,
|
|
382
362
|
) =>
|
|
@@ -392,8 +372,6 @@ let createConnectPluginExtension = (
|
|
|
392
372
|
let connectPluginExtension = ConnectPluginExtension.make(
|
|
393
373
|
~publishToPluginExtensionPoint,
|
|
394
374
|
~publishToAggregates,
|
|
395
|
-
~readModelNamesForSourceName,
|
|
396
|
-
~publishToReadModels,
|
|
397
375
|
~queryEngine,
|
|
398
376
|
~opts=Some(opts),
|
|
399
377
|
)
|
|
@@ -515,14 +493,6 @@ module MakeEventCollectorHelper = (
|
|
|
515
493
|
// that a user extension may publish to. The full plugin dict is fine —
|
|
516
494
|
// the runtime filters to ext.aggregateNames when invoking each extension.
|
|
517
495
|
~aggregateQueueUrls: dict<Pulumi.Output.t<string>>=Dict.make(),
|
|
518
|
-
// rmName → RM EventCollector SQS URL. Populated only for RMs that
|
|
519
|
-
// user extensions may enqueue events into directly. Plugin RMs fed
|
|
520
|
-
// through the normal EventTopic → EventColl subscription path don't
|
|
521
|
-
// need entries here.
|
|
522
|
-
~readModelQueueUrls: dict<Pulumi.Output.t<string>>=Dict.make(),
|
|
523
|
-
// The global readModelNamesForSourceName inversion (sourceName → [rmName]).
|
|
524
|
-
// Plain dict — no Pulumi outputs because it's pure name metadata.
|
|
525
|
-
~readModelNamesForSourceName: dict<array<string>>=Dict.make(),
|
|
526
496
|
) => {
|
|
527
497
|
let resources =
|
|
528
498
|
extensionPointsOutputs
|
|
@@ -649,10 +619,6 @@ module MakeEventCollectorHelper = (
|
|
|
649
619
|
) {
|
|
650
620
|
extensionsOutputs->Array.mapWithIndex((output, i) => {
|
|
651
621
|
let info = extensionRegistryInfos->Array.getUnsafe(i)
|
|
652
|
-
let rmNames =
|
|
653
|
-
readModelNamesForSourceName
|
|
654
|
-
->Dict.get(output.extensionPointName)
|
|
655
|
-
->Option.getOr([])
|
|
656
622
|
{
|
|
657
623
|
name: output.name,
|
|
658
624
|
specModule: info.specModule,
|
|
@@ -660,7 +626,6 @@ module MakeEventCollectorHelper = (
|
|
|
660
626
|
delegateModule: info.delegateModule,
|
|
661
627
|
extensionPointName: output.extensionPointName,
|
|
662
628
|
aggregateNames: output.aggregateNames,
|
|
663
|
-
readModelNames: rmNames,
|
|
664
629
|
}
|
|
665
630
|
})
|
|
666
631
|
} else {
|
|
@@ -724,8 +689,6 @@ module MakeEventCollectorHelper = (
|
|
|
724
689
|
extensions,
|
|
725
690
|
pluginExtensionPointCmdTopicUrl,
|
|
726
691
|
publishToAggregates: mergedAggregateUrls,
|
|
727
|
-
readModelQueueUrls,
|
|
728
|
-
readModelNamesForSourceName,
|
|
729
692
|
},
|
|
730
693
|
)
|
|
731
694
|
|
|
@@ -143,7 +143,7 @@ function serviceNameToJsonEventsHandlers(outputs, getServiceNames, handlers, get
|
|
|
143
143
|
return dict;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
function createExtensions(extensions, pluginName, publishToPluginExtensionPoint, publishToAggregates,
|
|
146
|
+
function createExtensions(extensions, pluginName, publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts) {
|
|
147
147
|
let groups = {};
|
|
148
148
|
extensions.forEach(bp => {
|
|
149
149
|
let epName = bp.Spec.name;
|
|
@@ -165,7 +165,7 @@ function createExtensions(extensions, pluginName, publishToPluginExtensionPoint,
|
|
|
165
165
|
mappings: allMappings
|
|
166
166
|
};
|
|
167
167
|
let ExtensionMaker = Extension_Builder$ReventlessCore.Make(First.Spec)(Mappings);
|
|
168
|
-
let extension = ExtensionMaker.make(publishToPluginExtensionPoint, publishToAggregates,
|
|
168
|
+
let extension = ExtensionMaker.make(publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts);
|
|
169
169
|
let ops = ExtensionMaker.operations(extension);
|
|
170
170
|
let registryInfo_specModule = First.Spec.moduleUrl;
|
|
171
171
|
let registryInfo_mappingsModule = First.moduleUrl;
|
|
@@ -222,18 +222,17 @@ function extractExtensionPointDefinitions(extensionPointsOutputs) {
|
|
|
222
222
|
function extractExtensionDefinitions(extensionsOutputs) {
|
|
223
223
|
return extensionsOutputs.map(extensionOutputs => ({
|
|
224
224
|
name: extensionOutputs.name,
|
|
225
|
-
extensionPointName: extensionOutputs.extensionPointName
|
|
226
|
-
dcbSources: []
|
|
225
|
+
extensionPointName: extensionOutputs.extensionPointName
|
|
227
226
|
}));
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
function createConnectPluginExtension(pluginDefinition, uiFragments, publishToPluginExtensionPoint, publishToAggregates,
|
|
229
|
+
function createConnectPluginExtension(pluginDefinition, uiFragments, publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts) {
|
|
231
230
|
return Output$Pulumi.unzip(ResourceAttribution_Deploytime$ReventlessCore.applyAttributed(pluginDefinition, pluginDefinition => {
|
|
232
231
|
let ConnectPluginExtension = PluginConnectExtension_Builder$ReventlessCore.Make({
|
|
233
232
|
pluginDefinition: pluginDefinition,
|
|
234
233
|
uiFragments: uiFragments
|
|
235
234
|
});
|
|
236
|
-
let connectPluginExtension = ConnectPluginExtension.make(publishToPluginExtensionPoint, publishToAggregates,
|
|
235
|
+
let connectPluginExtension = ConnectPluginExtension.make(publishToPluginExtensionPoint, publishToAggregates, queryEngine, opts);
|
|
237
236
|
let connectPluginExtensionOutputs = Component$ReventlessCore.outputs(connectPluginExtension);
|
|
238
237
|
let connectPluginExtensionIncomingEventHandler = Component$ReventlessCore.operations(connectPluginExtension).apply(param => param.incomingJsonEventsHandler);
|
|
239
238
|
return [
|
|
@@ -274,13 +273,11 @@ function MakeEventCollectorHelper(RuntimeEnvironment) {
|
|
|
274
273
|
eventCollectorUrn
|
|
275
274
|
];
|
|
276
275
|
};
|
|
277
|
-
let connect = (eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, pluginExtensionPointUnwrapped, pluginDefinition, uiFragmentsOpt, connectPluginExtensionIncomingEventHandler, extensionsHandlers, extensionPointsHandlers, connectPluginExtensionOutputs, extensionRegistryInfosOpt, extensionPointRegistryInfosOpt, aggregateQueueUrlsOpt
|
|
276
|
+
let connect = (eventCollector, eventTopics, extensionPointsOutputs, extensionsOutputs, pluginExtensionPointUnwrapped, pluginDefinition, uiFragmentsOpt, connectPluginExtensionIncomingEventHandler, extensionsHandlers, extensionPointsHandlers, connectPluginExtensionOutputs, extensionRegistryInfosOpt, extensionPointRegistryInfosOpt, aggregateQueueUrlsOpt) => {
|
|
278
277
|
let uiFragments = uiFragmentsOpt !== undefined ? Primitive_option.valFromOption(uiFragmentsOpt) : undefined;
|
|
279
278
|
let extensionRegistryInfos = extensionRegistryInfosOpt !== undefined ? extensionRegistryInfosOpt : [];
|
|
280
279
|
let extensionPointRegistryInfos = extensionPointRegistryInfosOpt !== undefined ? extensionPointRegistryInfosOpt : [];
|
|
281
280
|
let aggregateQueueUrls = aggregateQueueUrlsOpt !== undefined ? aggregateQueueUrlsOpt : ({});
|
|
282
|
-
let readModelQueueUrls = readModelQueueUrlsOpt !== undefined ? readModelQueueUrlsOpt : ({});
|
|
283
|
-
let readModelNamesForSourceName = readModelNamesForSourceNameOpt !== undefined ? readModelNamesForSourceNameOpt : ({});
|
|
284
281
|
let resources = Pulumi.all(extensionPointsOutputs.map(extensionPoint => extensionPoint.eventTopic)).apply(eventTopics => {
|
|
285
282
|
let base = eventTopics.map(eventTopic => eventTopic.resources).flat();
|
|
286
283
|
if (pluginExtensionPointUnwrapped !== undefined) {
|
|
@@ -340,15 +337,13 @@ function MakeEventCollectorHelper(RuntimeEnvironment) {
|
|
|
340
337
|
}) : undefined;
|
|
341
338
|
let extensions = extensionsOutputs.length === extensionRegistryInfos.length ? extensionsOutputs.map((output, i) => {
|
|
342
339
|
let info = extensionRegistryInfos[i];
|
|
343
|
-
let rmNames = Stdlib_Option.getOr(readModelNamesForSourceName[output.extensionPointName], []);
|
|
344
340
|
return {
|
|
345
341
|
name: output.name,
|
|
346
342
|
specModule: info.specModule,
|
|
347
343
|
mappingsModule: info.mappingsModule,
|
|
348
344
|
delegateModule: info.delegateModule,
|
|
349
345
|
extensionPointName: output.extensionPointName,
|
|
350
|
-
aggregateNames: output.aggregateNames
|
|
351
|
-
readModelNames: rmNames
|
|
346
|
+
aggregateNames: output.aggregateNames
|
|
352
347
|
};
|
|
353
348
|
}) : [];
|
|
354
349
|
let mergedAggregateUrls = {};
|
|
@@ -387,9 +382,7 @@ function MakeEventCollectorHelper(RuntimeEnvironment) {
|
|
|
387
382
|
connectExtension: connectExtension,
|
|
388
383
|
extensions: extensions,
|
|
389
384
|
pluginExtensionPointCmdTopicUrl: pluginExtensionPointCmdTopicUrl,
|
|
390
|
-
publishToAggregates: mergedAggregateUrls
|
|
391
|
-
readModelQueueUrls: readModelQueueUrls,
|
|
392
|
-
readModelNamesForSourceName: readModelNamesForSourceName
|
|
385
|
+
publishToAggregates: mergedAggregateUrls
|
|
393
386
|
});
|
|
394
387
|
PluginRuntimeBuilder.forPluginEventCollector(handler, eventTopics, param[4], undefined, undefined, eventCollector);
|
|
395
388
|
let r$1 = Component$ReventlessCore.outputs(eventCollector).resources[0];
|
|
@@ -999,10 +992,6 @@ let registerTaskSideEffectHandler = Builder_Helpers$ReventlessCore.registerTaskS
|
|
|
999
992
|
|
|
1000
993
|
let finishTasks = Builder_Helpers$ReventlessCore.finishTasks;
|
|
1001
994
|
|
|
1002
|
-
let readModelNamesForSourceName = Builder_Helpers$ReventlessCore.readModelNamesForSourceName;
|
|
1003
|
-
|
|
1004
|
-
let publishToReadModels = Builder_Helpers$ReventlessCore.publishToReadModels;
|
|
1005
|
-
|
|
1006
995
|
let finishReadModels = Builder_Helpers$ReventlessCore.finishReadModels;
|
|
1007
996
|
|
|
1008
997
|
let extractReadModelsOutputs = Builder_Helpers$ReventlessCore.extractReadModelsOutputs;
|
|
@@ -1058,8 +1047,6 @@ export {
|
|
|
1058
1047
|
taskSideEffectFinishFns,
|
|
1059
1048
|
registerTaskSideEffectHandler,
|
|
1060
1049
|
finishTasks,
|
|
1061
|
-
readModelNamesForSourceName,
|
|
1062
|
-
publishToReadModels,
|
|
1063
1050
|
finishReadModels,
|
|
1064
1051
|
extractReadModelsOutputs,
|
|
1065
1052
|
createReadModels,
|
|
@@ -154,6 +154,10 @@ module TestOps = {
|
|
|
154
154
|
) => promise<result<unit, EventLog.appendError>>,
|
|
155
155
|
replay: string => promise<array<AggSpec.event>>,
|
|
156
156
|
replayStream: (string, ~fromSeq: int=?) => Stream.t<AggSpec.event, string, unit>,
|
|
157
|
+
replayStream': (
|
|
158
|
+
string,
|
|
159
|
+
~fromSeq: int=?,
|
|
160
|
+
) => Stream.t<Message.event'<string, AggSpec.event>, string, unit>,
|
|
157
161
|
appendStream: (
|
|
158
162
|
int,
|
|
159
163
|
string,
|
|
@@ -170,6 +174,8 @@ module TestOps = {
|
|
|
170
174
|
append: mock.appendFn,
|
|
171
175
|
replay: mock.replayFn,
|
|
172
176
|
replayStream: (id, ~fromSeq as _=?) => mock.replayStreamFn(id),
|
|
177
|
+
replayStream': (id, ~fromSeq as _=?) =>
|
|
178
|
+
mock.getAll()->Array.filter(e => e.id == id)->Stream.fromIterable,
|
|
173
179
|
appendStream: (_startingSeqNr, _id, stream) => stream->Stream.runDrain,
|
|
174
180
|
latestSnapshot: async _ => Ok(None),
|
|
175
181
|
writeSnapshot: async (_, _) => Ok(),
|
|
@@ -199,6 +199,10 @@ function eventLog_replayStream(id, param) {
|
|
|
199
199
|
return mock.replayStreamFn(id);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
function eventLog_replayStream$p(id, param) {
|
|
203
|
+
return Stream.fromIterable(mock.getAll().filter(e => e.id === id));
|
|
204
|
+
}
|
|
205
|
+
|
|
202
206
|
function eventLog_appendStream(_startingSeqNr, _id, stream) {
|
|
203
207
|
return Stream.runDrain(stream);
|
|
204
208
|
}
|
|
@@ -221,6 +225,7 @@ let eventLog = {
|
|
|
221
225
|
append: eventLog_append,
|
|
222
226
|
replay: eventLog_replay,
|
|
223
227
|
replayStream: eventLog_replayStream,
|
|
228
|
+
"replayStream'": eventLog_replayStream$p,
|
|
224
229
|
appendStream: eventLog_appendStream,
|
|
225
230
|
latestSnapshot: eventLog_latestSnapshot,
|
|
226
231
|
writeSnapshot: eventLog_writeSnapshot
|
|
@@ -130,6 +130,10 @@ module TestOps = {
|
|
|
130
130
|
) => promise<result<unit, EventLog.appendError>>,
|
|
131
131
|
replay: string => promise<array<AggSpec.event>>,
|
|
132
132
|
replayStream: (string, ~fromSeq: int=?) => Stream.t<AggSpec.event, string, unit>,
|
|
133
|
+
replayStream': (
|
|
134
|
+
string,
|
|
135
|
+
~fromSeq: int=?,
|
|
136
|
+
) => Stream.t<Message.event'<string, AggSpec.event>, string, unit>,
|
|
133
137
|
appendStream: (
|
|
134
138
|
int,
|
|
135
139
|
string,
|
|
@@ -145,6 +149,8 @@ module TestOps = {
|
|
|
145
149
|
append: mock.appendFn,
|
|
146
150
|
replay: mock.replayFn,
|
|
147
151
|
replayStream: (id, ~fromSeq as _=?) => mock.replayStreamFn(id),
|
|
152
|
+
replayStream': (id, ~fromSeq as _=?) =>
|
|
153
|
+
mock.getAll()->Array.filter(e => e.id == id)->Stream.fromIterable,
|
|
148
154
|
appendStream: (_startingSeqNr, _id, stream) => stream->Stream.runDrain,
|
|
149
155
|
latestSnapshot: async _ => Ok(None),
|
|
150
156
|
writeSnapshot: async (_, _) => Ok(),
|
|
@@ -156,6 +156,10 @@ function eventLog_replayStream(id, param) {
|
|
|
156
156
|
return mock.replayStreamFn(id);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function eventLog_replayStream$p(id, param) {
|
|
160
|
+
return Stream.fromIterable(mock.getAll().filter(e => e.id === id));
|
|
161
|
+
}
|
|
162
|
+
|
|
159
163
|
function eventLog_appendStream(_startingSeqNr, _id, stream) {
|
|
160
164
|
return Stream.runDrain(stream);
|
|
161
165
|
}
|
|
@@ -178,6 +182,7 @@ let eventLog = {
|
|
|
178
182
|
append: eventLog_append,
|
|
179
183
|
replay: eventLog_replay,
|
|
180
184
|
replayStream: eventLog_replayStream,
|
|
185
|
+
"replayStream'": eventLog_replayStream$p,
|
|
181
186
|
appendStream: eventLog_appendStream,
|
|
182
187
|
latestSnapshot: eventLog_latestSnapshot,
|
|
183
188
|
writeSnapshot: eventLog_writeSnapshot
|
|
@@ -141,6 +141,10 @@ module TestOps = {
|
|
|
141
141
|
) => promise<result<unit, EventLog.appendError>>,
|
|
142
142
|
replay: string => promise<array<AggSpec.event>>,
|
|
143
143
|
replayStream: (string, ~fromSeq: int=?) => Stream.t<AggSpec.event, string, unit>,
|
|
144
|
+
replayStream': (
|
|
145
|
+
string,
|
|
146
|
+
~fromSeq: int=?,
|
|
147
|
+
) => Stream.t<Message.event'<string, AggSpec.event>, string, unit>,
|
|
144
148
|
appendStream: (
|
|
145
149
|
int,
|
|
146
150
|
string,
|
|
@@ -157,6 +161,8 @@ module TestOps = {
|
|
|
157
161
|
append: mock.appendFn,
|
|
158
162
|
replay: mock.replayFn,
|
|
159
163
|
replayStream: (id, ~fromSeq as _=?) => mock.replayStreamFn(id),
|
|
164
|
+
replayStream': (id, ~fromSeq as _=?) =>
|
|
165
|
+
mock.getAll()->Array.filter(e => e.id == id)->Stream.fromIterable,
|
|
160
166
|
appendStream: (_startingSeqNr, _id, stream) => stream->Stream.runDrain,
|
|
161
167
|
latestSnapshot: async _ => Ok(None),
|
|
162
168
|
writeSnapshot: async (_, _) => Ok(),
|
|
@@ -191,6 +191,10 @@ function eventLog_replayStream(id, param) {
|
|
|
191
191
|
return mock.replayStreamFn(id);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
function eventLog_replayStream$p(id, param) {
|
|
195
|
+
return Stream.fromIterable(mock.getAll().filter(e => e.id === id));
|
|
196
|
+
}
|
|
197
|
+
|
|
194
198
|
function eventLog_appendStream(_startingSeqNr, _id, stream) {
|
|
195
199
|
return Stream.runDrain(stream);
|
|
196
200
|
}
|
|
@@ -213,6 +217,7 @@ let eventLog = {
|
|
|
213
217
|
append: eventLog_append,
|
|
214
218
|
replay: eventLog_replay,
|
|
215
219
|
replayStream: eventLog_replayStream,
|
|
220
|
+
"replayStream'": eventLog_replayStream$p,
|
|
216
221
|
appendStream: eventLog_appendStream,
|
|
217
222
|
latestSnapshot: eventLog_latestSnapshot,
|
|
218
223
|
writeSnapshot: eventLog_writeSnapshot
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// A command with a stable id (one an Extension derived from a published event)
|
|
2
|
+
// that the stream already holds events for is accepted again with nothing new.
|
|
3
|
+
// A command with a random id is decided every time, as before.
|
|
4
|
+
|
|
5
|
+
open JestGlobals
|
|
6
|
+
|
|
7
|
+
module AggSpec = {
|
|
8
|
+
module Id = Reventless.Id.StringPure
|
|
9
|
+
let name = "RepeatTestAggregate"
|
|
10
|
+
|
|
11
|
+
@schema
|
|
12
|
+
type command = Count({by: int})
|
|
13
|
+
|
|
14
|
+
@schema
|
|
15
|
+
type event = Counted({by: int})
|
|
16
|
+
|
|
17
|
+
@schema
|
|
18
|
+
type error = Never
|
|
19
|
+
|
|
20
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// No idempotency rule of its own: every Count appends, which is what makes the
|
|
24
|
+
// framework's drop visible.
|
|
25
|
+
module TestDecision = {
|
|
26
|
+
module Spec = AggSpec
|
|
27
|
+
type state = {total: int}
|
|
28
|
+
let initialState = {total: 0}
|
|
29
|
+
let snapshot = None
|
|
30
|
+
let moduleUrl: string = %raw(`import.meta.url`)
|
|
31
|
+
|
|
32
|
+
let evolve = (state: state, event: AggSpec.event): state =>
|
|
33
|
+
switch event {
|
|
34
|
+
| Counted({by}) => {total: state.total + by}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let decide = (_state: state, command: AggSpec.command): result<
|
|
38
|
+
array<AggSpec.event>,
|
|
39
|
+
AggSpec.error,
|
|
40
|
+
> =>
|
|
41
|
+
switch command {
|
|
42
|
+
| Count({by}) => Ok([AggSpec.Counted({by: by})])
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// An event log with real optimistic concurrency, holding envelopes so the
|
|
47
|
+
// `causationId`s survive.
|
|
48
|
+
let stored: ref<array<Message.event'<string, AggSpec.event>>> = ref([])
|
|
49
|
+
let eventsFor = id => stored.contents->Array.filter(e => e.id == id)
|
|
50
|
+
|
|
51
|
+
module OuterEventLog = EventLog
|
|
52
|
+
|
|
53
|
+
module TestOps = {
|
|
54
|
+
module Spec = AggSpec
|
|
55
|
+
module EventLog = {
|
|
56
|
+
module Spec = {
|
|
57
|
+
module Id = AggSpec.Id
|
|
58
|
+
let name = "RepeatMockEventLog"
|
|
59
|
+
@schema
|
|
60
|
+
type event = AggSpec.event
|
|
61
|
+
}
|
|
62
|
+
type operations = {
|
|
63
|
+
append: (
|
|
64
|
+
int,
|
|
65
|
+
string,
|
|
66
|
+
array<Message.event'<string, AggSpec.event>>,
|
|
67
|
+
) => promise<result<unit, EventLog.appendError>>,
|
|
68
|
+
replay: string => promise<array<AggSpec.event>>,
|
|
69
|
+
replayStream: (string, ~fromSeq: int=?) => Stream.t<AggSpec.event, string, unit>,
|
|
70
|
+
replayStream': (
|
|
71
|
+
string,
|
|
72
|
+
~fromSeq: int=?,
|
|
73
|
+
) => Stream.t<Message.event'<string, AggSpec.event>, string, unit>,
|
|
74
|
+
appendStream: (
|
|
75
|
+
int,
|
|
76
|
+
string,
|
|
77
|
+
Stream.t<AggSpec.event, string, unit>,
|
|
78
|
+
) => Effect.t<unit, string, unit>,
|
|
79
|
+
latestSnapshot: string => promise<result<option<EventLog.snapshot>, string>>,
|
|
80
|
+
writeSnapshot: (string, EventLog.snapshot) => promise<result<unit, string>>,
|
|
81
|
+
}
|
|
82
|
+
type component = Component.t<OuterEventLog.t, OuterEventLog.outputs, operations>
|
|
83
|
+
let make = (~name as _: string, ~owner as _=?, ~opts as _=?): component => Obj.magic(0)
|
|
84
|
+
}
|
|
85
|
+
let eventLog: EventLog.operations = {
|
|
86
|
+
append: async (seqNr, id, newEvents) =>
|
|
87
|
+
if seqNr != eventsFor(id)->Array.length {
|
|
88
|
+
Error(OuterEventLog.Conflict)
|
|
89
|
+
} else {
|
|
90
|
+
stored := stored.contents->Array.concat(newEvents)
|
|
91
|
+
Ok()
|
|
92
|
+
},
|
|
93
|
+
replay: async id => eventsFor(id)->Array.map(e => e.event),
|
|
94
|
+
replayStream: (id, ~fromSeq=0) =>
|
|
95
|
+
eventsFor(id)->Array.map(e => e.event)->Array.slice(~start=fromSeq)->Stream.fromIterable,
|
|
96
|
+
replayStream': (id, ~fromSeq=0) =>
|
|
97
|
+
eventsFor(id)->Array.slice(~start=fromSeq)->Stream.fromIterable,
|
|
98
|
+
appendStream: (_seqNr, _id, stream) => stream->Stream.runDrain,
|
|
99
|
+
latestSnapshot: async _ => Ok(None),
|
|
100
|
+
writeSnapshot: async (_, _) => Ok(),
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module TestHandler = Aggregate_Callback.Make(AggSpec, TestDecision, TestOps)
|
|
105
|
+
|
|
106
|
+
// The published event an Extension would have mapped the command from.
|
|
107
|
+
let publishedMeta: Message.meta = {
|
|
108
|
+
service: "Ordering.Orders",
|
|
109
|
+
time: "2024-01-01T00:00:00Z",
|
|
110
|
+
msgId: "published-event-msg",
|
|
111
|
+
correlationId: "root",
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let run = async (meta: Message.meta) =>
|
|
115
|
+
await TestHandler.handleCommands(
|
|
116
|
+
Stream.fromIterable([
|
|
117
|
+
{
|
|
118
|
+
ReventlessInfra.CommandTopic.command: {
|
|
119
|
+
Message.id: "counter-1",
|
|
120
|
+
meta,
|
|
121
|
+
command: AggSpec.Count({by: 1}),
|
|
122
|
+
},
|
|
123
|
+
reference: meta.msgId,
|
|
124
|
+
},
|
|
125
|
+
]),
|
|
126
|
+
)->Effect.runPromise
|
|
127
|
+
|
|
128
|
+
let _ = beforeEach(() => {
|
|
129
|
+
stored := []
|
|
130
|
+
TestHandler.resetCache()
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
describe("Aggregate_Callback drops a repeated command", () => {
|
|
134
|
+
testPromise("a command with a stable id appends once however often it arrives", async () => {
|
|
135
|
+
// What ExtensionMapping produces for one published event: the same meta each time.
|
|
136
|
+
let derived = Message.deriveStableMeta(~parent=publishedMeta, ~service=AggSpec.name, ~index=0)
|
|
137
|
+
let first = await run(derived)
|
|
138
|
+
expect(first)->toEqual([Ok(derived.msgId)])
|
|
139
|
+
let again = await run(derived)
|
|
140
|
+
expect(again)->toEqual([Ok(derived.msgId)]) // accepted, not rejected
|
|
141
|
+
let third = await run(derived)
|
|
142
|
+
expect(third)->toEqual([Ok(derived.msgId)])
|
|
143
|
+
expect(stored.contents->Array.length)->toBe(1)
|
|
144
|
+
expect((stored.contents->Array.getUnsafe(0)).meta.causationId)->toEqual(Some(derived.msgId))
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
testPromise("a second derived command for another input still appends", async () => {
|
|
148
|
+
let one = Message.deriveStableMeta(~parent=publishedMeta, ~service=AggSpec.name, ~index=0)
|
|
149
|
+
let two = Message.deriveStableMeta(
|
|
150
|
+
~parent={...publishedMeta, msgId: "another-published-event"},
|
|
151
|
+
~service=AggSpec.name,
|
|
152
|
+
~index=0,
|
|
153
|
+
)
|
|
154
|
+
let _ = await run(one)
|
|
155
|
+
let _ = await run(two)
|
|
156
|
+
let _ = await run(one)
|
|
157
|
+
expect(stored.contents->Array.length)->toBe(2)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
testPromise("a command with a random id is decided every time", async () => {
|
|
161
|
+
// What the API or a person sends: `deriveMeta` strips the mark and mints a
|
|
162
|
+
// fresh id, so nothing is dropped.
|
|
163
|
+
let fresh = () => Message.deriveMeta(~parent=publishedMeta, ~service=AggSpec.name)
|
|
164
|
+
let a = fresh()
|
|
165
|
+
let _ = await run(a)
|
|
166
|
+
let _ = await run(a) // the very same envelope, redelivered without a stable id
|
|
167
|
+
expect(stored.contents->Array.length)->toBe(2)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
testPromise("two copies in one batch append once", async () => {
|
|
171
|
+
let derived = Message.deriveStableMeta(~parent=publishedMeta, ~service=AggSpec.name, ~index=0)
|
|
172
|
+
let item = {
|
|
173
|
+
ReventlessInfra.CommandTopic.command: {
|
|
174
|
+
Message.id: "counter-1",
|
|
175
|
+
meta: derived,
|
|
176
|
+
command: AggSpec.Count({by: 1}),
|
|
177
|
+
},
|
|
178
|
+
reference: derived.msgId,
|
|
179
|
+
}
|
|
180
|
+
let results = await TestHandler.handleCommands(
|
|
181
|
+
Stream.fromIterable([item, item]),
|
|
182
|
+
)->Effect.runPromise
|
|
183
|
+
expect(results)->toEqual([Ok(derived.msgId), Ok(derived.msgId)])
|
|
184
|
+
expect(stored.contents->Array.length)->toBe(1)
|
|
185
|
+
})
|
|
186
|
+
})
|