@reventlessdev/reventless-core 3.0.0-alpha.341 → 3.0.0-alpha.343
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 +23 -0
- package/package.json +7 -7
- package/src/Projection.res +32 -4
- package/src/Projection.res.mjs +51 -4
- package/src/ViewChange.res +1 -9
- package/src/ViewChange.res.mjs +2 -13
- package/src/admin/Platform_ComponentDefinitionsApi.res +29 -1
- package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +47 -1
- package/src/admin/Platform_PluginStructuresApi.res +4 -3
- package/src/admin/Platform_PluginStructuresApi.res.mjs +5 -1
- package/src/components/Api/SuryToJsonSchema.res +7 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +18 -0
- package/src/components/Dcb/Dcb_Builder.res +59 -0
- package/src/components/Dcb/Dcb_Builder.res.mjs +48 -3
- package/src/components/DcbEventLog/DcbEventLog.res +2 -0
- package/src/components/DcbEventLog/DcbEventLog_Adapter.res +7 -0
- package/src/components/DcbEventLog/DcbEventLog_Builder.res +12 -3
- package/src/components/DcbEventLog/DcbEventLog_Builder.res.mjs +5 -3
- package/src/components/DcbEventLog/DcbEventLog_Operations.res +3 -0
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +3 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +2 -2
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +156 -107
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +174 -154
- package/src/components/StateChangeSlice/StateChangeSlice.res +3 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res +6 -0
- package/src/components/StateChangeSlice/StateChangeSlice_Builder.res.mjs +5 -4
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +369 -279
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +210 -166
- package/src/plugin/component/Plugin_Structure.res +45 -0
- package/src/plugin/component/Plugin_Structure.res.mjs +42 -1
- package/src/util/Logger.res +5 -5
- package/src/util/Logger.res.mjs +3 -3
- package/tests/admin/AdminApiSchemaDriftTest.res +23 -0
- package/tests/admin/AdminApiSchemaDriftTest.res.mjs +21 -1
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res +1 -0
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +1 -0
- package/tests/admin/Platform_PluginStructuresApiTest.res +1 -0
- package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +1 -0
- package/tests/api/QuantitySemanticTest.res +68 -0
- package/tests/api/QuantitySemanticTest.res.mjs +68 -0
- package/tests/commandgenerator/OwnerActingTest.res.mjs +1 -1
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +1 -1
- package/tests/dcb/DcbFenceCountReadTest.res +213 -0
- package/tests/dcb/DcbFenceCountReadTest.res.mjs +358 -0
- package/tests/dcb/DcbPiiSliceTest.res.mjs +1 -1
- package/tests/dcb/DcbReadsNothingTest.res.mjs +1 -1
- package/tests/dcb/DcbScopeInferenceTest.res +143 -2
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +192 -2
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +22 -22
- package/tests/dcb/DcbTagTest.res +68 -0
- package/tests/dcb/DcbTagTest.res.mjs +86 -10
- package/tests/dcb/DcbValidationTest.res.mjs +1 -1
- package/tests/logger/LoggerLazyTest.res.mjs +3 -3
- package/tests/plugin/PluginStructureAccessTest.res +1 -0
- package/tests/plugin/PluginStructureAccessTest.res.mjs +1 -1
- package/tests/plugin/PluginStructureTest.res +61 -0
- package/tests/plugin/PluginStructureTest.res.mjs +78 -32
- package/tests/plugin/StateChange/PsRateSession.res +37 -0
- package/tests/plugin/StateChange/PsRateSession.res.mjs +80 -0
- package/tests/plugin/pluginDefinitionRequiredScalars.txt +10 -0
- package/tests/projection/ViewChangeTest.res +32 -0
- package/tests/projection/ViewChangeTest.res.mjs +57 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
4
|
import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
|
|
5
|
+
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
5
6
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
6
7
|
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
7
8
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
@@ -33,7 +34,8 @@ let todoRowSchema = Sury.$schema(s => ({
|
|
|
33
34
|
retryCount: s.m(Sury.int32),
|
|
34
35
|
maxRetries: s.m(Sury.$option(Sury.int32)),
|
|
35
36
|
lastError: s.m(Sury.$option(Sury.string)),
|
|
36
|
-
source: s.m(Sury.$option(Message$ReventlessCore.flowSourceSchema))
|
|
37
|
+
source: s.m(Sury.$option(Message$ReventlessCore.flowSourceSchema)),
|
|
38
|
+
claimedUntil: s.m(Sury.$option(Sury.string))
|
|
37
39
|
}));
|
|
38
40
|
|
|
39
41
|
function todoRowSchemaFor(itemSchema) {
|
|
@@ -46,10 +48,21 @@ function todoRowSchemaFor(itemSchema) {
|
|
|
46
48
|
retryCount: s.m(Sury.int32),
|
|
47
49
|
maxRetries: s.m(Sury.$option(Sury.int32)),
|
|
48
50
|
lastError: s.m(Sury.$option(Sury.string)),
|
|
49
|
-
source: s.m(Sury.$option(Message$ReventlessCore.flowSourceSchema))
|
|
51
|
+
source: s.m(Sury.$option(Message$ReventlessCore.flowSourceSchema)),
|
|
52
|
+
claimedUntil: s.m(Sury.$option(Sury.string))
|
|
50
53
|
}));
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
let claimMs = 15 * 60 * 1000;
|
|
57
|
+
|
|
58
|
+
function claimRanOut(row, now) {
|
|
59
|
+
if (row.status === "Processing") {
|
|
60
|
+
return Stdlib_Option.mapOr(row.claimedUntil, true, until => Primitive_object.lessthan(new Date(until), now));
|
|
61
|
+
} else {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
53
66
|
function Make(Spec) {
|
|
54
67
|
return Translation => {
|
|
55
68
|
let todoItems = {};
|
|
@@ -170,7 +183,7 @@ function Make(Spec) {
|
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
185
|
};
|
|
173
|
-
let phase2 = async (publishJsons, capabilities, publishJsonsAndWait) => {
|
|
186
|
+
let phase2 = async (publishJsons, capabilities, publishJsonsAndWait, claim) => {
|
|
174
187
|
let publishJsons$1 = CommandSent$ReventlessCore.announcing(`OutboundTranslationSlice(` + Spec.name + `)`, publishJsons);
|
|
175
188
|
let publishJsonsAndWait$1 = Stdlib_Option.map(publishJsonsAndWait, wait => CommandSent$ReventlessCore.announcingAndWaiting(`OutboundTranslationSlice(` + Spec.name + `)`, wait));
|
|
176
189
|
let newlyAbandoned = [];
|
|
@@ -187,164 +200,175 @@ function Make(Spec) {
|
|
|
187
200
|
});
|
|
188
201
|
let pending = Object.entries(todoItems).filter(param => {
|
|
189
202
|
let row = param[1];
|
|
190
|
-
if (row.status === "Pending") {
|
|
203
|
+
if (row.status === "Pending" || row.status === "Failed" && row.retryCount < Spec.maxRetries) {
|
|
191
204
|
return true;
|
|
192
|
-
} else if (row.status === "Failed") {
|
|
193
|
-
return row.retryCount < Spec.maxRetries;
|
|
194
205
|
} else {
|
|
195
|
-
return
|
|
206
|
+
return claimRanOut(row, new Date());
|
|
196
207
|
}
|
|
197
208
|
});
|
|
198
209
|
await Stdlib_Array.reduce(pending, Promise.resolve(), async (prev, param) => {
|
|
199
|
-
let
|
|
210
|
+
let read = param[1];
|
|
200
211
|
let id = param[0];
|
|
201
212
|
await prev;
|
|
202
|
-
let
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
let newrecord = {...read};
|
|
214
|
+
newrecord.claimedUntil = new Date(Date.now() + claimMs).toISOString();
|
|
215
|
+
newrecord.processedAt = new Date().toISOString();
|
|
216
|
+
newrecord.status = "Processing";
|
|
217
|
+
let ours = claim !== undefined ? await claim(id, newrecord) : true;
|
|
218
|
+
if (ours) {
|
|
219
|
+
todoItems[id] = newrecord;
|
|
220
|
+
let data = read.item;
|
|
221
|
+
let opened;
|
|
222
|
+
if (typeof data === "object" && data !== null && !Array.isArray(data) && Primitive_object.notequal(personalFields, [])) {
|
|
223
|
+
let data$1 = await Pii$Reventless.openRecord(Spec.outboundItemSchema, data);
|
|
224
|
+
if (data$1.TAG === "Ok") {
|
|
225
|
+
let data$2 = data$1._0;
|
|
226
|
+
let field = Pii$Reventless.goneField(Spec.outboundItemSchema, data$2);
|
|
227
|
+
opened = field !== undefined ? ({
|
|
228
|
+
TAG: "Error",
|
|
229
|
+
_0: {
|
|
230
|
+
NAME: "Gone",
|
|
231
|
+
VAL: field
|
|
232
|
+
}
|
|
233
|
+
}) : ({
|
|
234
|
+
TAG: "Ok",
|
|
235
|
+
_0: data$2
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
opened = {
|
|
210
239
|
TAG: "Error",
|
|
211
240
|
_0: {
|
|
212
|
-
NAME: "
|
|
213
|
-
VAL:
|
|
241
|
+
NAME: "Unopened",
|
|
242
|
+
VAL: Pii$Reventless.errorMessage(data$1._0)
|
|
214
243
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
_0: data$2
|
|
218
|
-
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
219
246
|
} else {
|
|
220
247
|
opened = {
|
|
221
|
-
TAG: "
|
|
222
|
-
_0:
|
|
223
|
-
NAME: "Unopened",
|
|
224
|
-
VAL: Pii$Reventless.errorMessage(data$1._0)
|
|
225
|
-
}
|
|
248
|
+
TAG: "Ok",
|
|
249
|
+
_0: data
|
|
226
250
|
};
|
|
227
251
|
}
|
|
228
|
-
|
|
229
|
-
opened
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} catch (raw_exn) {
|
|
239
|
-
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
240
|
-
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
241
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to decode outboundItem: ` + errMsg));
|
|
242
|
-
item = undefined;
|
|
243
|
-
}
|
|
244
|
-
} else {
|
|
245
|
-
let match = opened._0;
|
|
246
|
-
if (match.NAME === "Gone") {
|
|
247
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), id + `: its ` + match.VAL + ` was erased; nothing to do`));
|
|
248
|
-
let newrecord = {...row};
|
|
249
|
-
newrecord.completedAt = new Date().toISOString();
|
|
250
|
-
newrecord.status = "Completed";
|
|
251
|
-
todoItems[id] = newrecord;
|
|
252
|
-
item = undefined;
|
|
252
|
+
let item;
|
|
253
|
+
if (opened.TAG === "Ok") {
|
|
254
|
+
try {
|
|
255
|
+
item = Primitive_option.some(Util_Sury$Reventless.fromJson(opened._0, Spec.outboundItemSchema));
|
|
256
|
+
} catch (raw_exn) {
|
|
257
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
258
|
+
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
259
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), `failed to decode outboundItem: ` + errMsg));
|
|
260
|
+
item = undefined;
|
|
261
|
+
}
|
|
253
262
|
} else {
|
|
254
|
-
let
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
let match = opened._0;
|
|
264
|
+
if (match.NAME === "Gone") {
|
|
265
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), id + `: its ` + match.VAL + ` was erased; nothing to do`));
|
|
266
|
+
let newrecord$1 = {...read};
|
|
267
|
+
newrecord$1.completedAt = new Date().toISOString();
|
|
268
|
+
newrecord$1.status = "Completed";
|
|
269
|
+
todoItems[id] = newrecord$1;
|
|
270
|
+
item = undefined;
|
|
271
|
+
} else {
|
|
272
|
+
let why = match.VAL;
|
|
273
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), id + `: its work item does not open: ` + why));
|
|
274
|
+
let updated = afterFailedAttempt(read, why);
|
|
275
|
+
todoItems[id] = updated;
|
|
276
|
+
if (updated.status === "Abandoned") {
|
|
277
|
+
newlyAbandoned.push(id);
|
|
278
|
+
}
|
|
279
|
+
item = undefined;
|
|
260
280
|
}
|
|
261
|
-
item = undefined;
|
|
262
281
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
result
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
if (result.TAG === "Ok") {
|
|
283
|
-
let match$1 = result._0;
|
|
284
|
-
if (match$1 !== undefined) {
|
|
285
|
-
let commandJson;
|
|
286
|
-
try {
|
|
287
|
-
commandJson = Util_Sury$Reventless.toJson(match$1[1], Spec.inboundCommandSchema);
|
|
288
|
-
} catch (raw_exn$2) {
|
|
289
|
-
let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
|
|
290
|
-
let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
|
|
291
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to encode inbound command: ` + errMsg$1));
|
|
292
|
-
commandJson = undefined;
|
|
293
|
-
}
|
|
294
|
-
if (commandJson !== undefined) {
|
|
282
|
+
if (item === undefined) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
let result;
|
|
286
|
+
try {
|
|
287
|
+
result = await Translation.translate(id, Primitive_option.valFromOption(item), capabilities);
|
|
288
|
+
} catch (raw_exn$1) {
|
|
289
|
+
let exn$1 = Primitive_exceptions.internalToException(raw_exn$1);
|
|
290
|
+
let msg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$1), Stdlib_JsExn.message), "unknown error");
|
|
291
|
+
result = {
|
|
292
|
+
TAG: "Error",
|
|
293
|
+
_0: msg
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (result.TAG === "Ok") {
|
|
297
|
+
let match$1 = result._0;
|
|
298
|
+
if (match$1 !== undefined) {
|
|
299
|
+
let commandJson;
|
|
295
300
|
try {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
let
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
301
|
+
commandJson = Util_Sury$Reventless.toJson(match$1[1], Spec.inboundCommandSchema);
|
|
302
|
+
} catch (raw_exn$2) {
|
|
303
|
+
let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
|
|
304
|
+
let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
|
|
305
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), `failed to encode inbound command: ` + errMsg$1));
|
|
306
|
+
commandJson = undefined;
|
|
307
|
+
}
|
|
308
|
+
if (commandJson !== undefined) {
|
|
309
|
+
try {
|
|
310
|
+
let msg_id = match$1[0];
|
|
311
|
+
let msg_meta = makeMeta(read);
|
|
312
|
+
let msg$1 = {
|
|
313
|
+
id: msg_id,
|
|
314
|
+
meta: msg_meta,
|
|
315
|
+
commandJson: commandJson
|
|
316
|
+
};
|
|
317
|
+
let refusal;
|
|
318
|
+
if (publishJsonsAndWait$1 !== undefined) {
|
|
319
|
+
let match$2 = (await publishJsonsAndWait$1([msg$1]))[0];
|
|
320
|
+
if (match$2 !== undefined) {
|
|
321
|
+
switch (match$2.TAG) {
|
|
322
|
+
case "Rejected" :
|
|
323
|
+
refusal = [
|
|
324
|
+
match$2.cause,
|
|
325
|
+
CommandTopic_Helpers$ReventlessCore.describeRefusal(match$2.errorCode, match$2.errorDetail)
|
|
326
|
+
];
|
|
327
|
+
break;
|
|
328
|
+
case "Accepted" :
|
|
329
|
+
case "Pending" :
|
|
330
|
+
refusal = undefined;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
refusal = undefined;
|
|
318
335
|
}
|
|
319
336
|
} else {
|
|
337
|
+
await publishJsons$1([msg$1]);
|
|
320
338
|
refusal = undefined;
|
|
321
339
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
340
|
+
if (refusal !== undefined) {
|
|
341
|
+
let updated$1 = afterRefusal(read, refusal[0], refusal[1]);
|
|
342
|
+
todoItems[id] = updated$1;
|
|
343
|
+
if (updated$1.status === "Abandoned") {
|
|
344
|
+
newlyAbandoned.push(id);
|
|
345
|
+
return;
|
|
346
|
+
} else {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
let newrecord$2 = {...read};
|
|
351
|
+
newrecord$2.completedAt = new Date().toISOString();
|
|
352
|
+
newrecord$2.status = "Completed";
|
|
353
|
+
todoItems[id] = newrecord$2;
|
|
354
|
+
return;
|
|
355
|
+
} catch (raw_exn$3) {
|
|
356
|
+
let exn$3 = Primitive_exceptions.internalToException(raw_exn$3);
|
|
357
|
+
let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$3), Stdlib_JsExn.message), "unknown");
|
|
358
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), `failed to publish command: ` + errMsg$2));
|
|
359
|
+
let updated$2 = afterFailedAttempt(read, errMsg$2);
|
|
360
|
+
todoItems[id] = updated$2;
|
|
361
|
+
if (updated$2.status === "Abandoned") {
|
|
330
362
|
newlyAbandoned.push(id);
|
|
331
363
|
return;
|
|
332
364
|
} else {
|
|
333
365
|
return;
|
|
334
366
|
}
|
|
335
367
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return;
|
|
341
|
-
} catch (raw_exn$3) {
|
|
342
|
-
let exn$3 = Primitive_exceptions.internalToException(raw_exn$3);
|
|
343
|
-
let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$3), Stdlib_JsExn.message), "unknown");
|
|
344
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to publish command: ` + errMsg$2));
|
|
345
|
-
let updated$2 = afterFailedAttempt(row, errMsg$2);
|
|
346
|
-
todoItems[id] = updated$2;
|
|
347
|
-
if (updated$2.status === "Abandoned") {
|
|
368
|
+
} else {
|
|
369
|
+
let updated$3 = afterFailedAttempt(read, undefined);
|
|
370
|
+
todoItems[id] = updated$3;
|
|
371
|
+
if (updated$3.status === "Abandoned") {
|
|
348
372
|
newlyAbandoned.push(id);
|
|
349
373
|
return;
|
|
350
374
|
} else {
|
|
@@ -352,31 +376,25 @@ function Make(Spec) {
|
|
|
352
376
|
}
|
|
353
377
|
}
|
|
354
378
|
} else {
|
|
355
|
-
let
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
} else {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
379
|
+
let newrecord$3 = {...read};
|
|
380
|
+
newrecord$3.completedAt = new Date().toISOString();
|
|
381
|
+
newrecord$3.status = "Completed";
|
|
382
|
+
todoItems[id] = newrecord$3;
|
|
383
|
+
return;
|
|
363
384
|
}
|
|
364
385
|
} else {
|
|
365
|
-
let
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
386
|
+
let updated$4 = afterFailedAttempt(read, result._0);
|
|
387
|
+
todoItems[id] = updated$4;
|
|
388
|
+
if (updated$4.status === "Abandoned") {
|
|
389
|
+
newlyAbandoned.push(id);
|
|
390
|
+
return;
|
|
391
|
+
} else {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
370
394
|
}
|
|
371
395
|
} else {
|
|
372
|
-
|
|
373
|
-
todoItems
|
|
374
|
-
if (updated$4.status === "Abandoned") {
|
|
375
|
-
newlyAbandoned.push(id);
|
|
376
|
-
return;
|
|
377
|
-
} else {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
396
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(read.source, EffectLogger$ReventlessCore.idsOfSource), id + `: another runtime holds it; left to that one`));
|
|
397
|
+
return Stdlib_Dict.$$delete(todoItems, id);
|
|
380
398
|
}
|
|
381
399
|
});
|
|
382
400
|
await Stdlib_Array.reduce(newlyAbandoned, Promise.resolve(), async (prev, id) => {
|
|
@@ -400,6 +418,8 @@ export {
|
|
|
400
418
|
todoStatusSchema,
|
|
401
419
|
todoRowSchema,
|
|
402
420
|
todoRowSchemaFor,
|
|
421
|
+
claimMs,
|
|
422
|
+
claimRanOut,
|
|
403
423
|
Make,
|
|
404
424
|
}
|
|
405
425
|
/* todoStatusSchema Not a pure module */
|
|
@@ -33,6 +33,9 @@ module type T = {
|
|
|
33
33
|
clause (instead of an AND-ed composite) so the decision read is a real
|
|
34
34
|
secondary-tag read. */
|
|
35
35
|
~crossPartitionTagKeys: array<string>=?,
|
|
36
|
+
/** The boundary's pairs: the types a slice reads by its own key across
|
|
37
|
+
partitions. The slice reads those it is the reader of from the index. */
|
|
38
|
+
~crossPartitionPairs: array<Reventless.DcbScopeInference.pair>=?,
|
|
36
39
|
/** This slice's partition, as `Dcb_Builder` derives it for the whole boundary. */
|
|
37
40
|
~partitionTag: Reventless.DcbTag.derivedPartitionTag=?,
|
|
38
41
|
~runtime: ReventlessInfra.RuntimeHints.t=?,
|
|
@@ -13,6 +13,7 @@ module Make = (
|
|
|
13
13
|
let makeJsonHandler = (
|
|
14
14
|
~tagKeysByEventType,
|
|
15
15
|
~crossPartitionTagKeys,
|
|
16
|
+
~crossPartitionPairs,
|
|
16
17
|
~partitionTag,
|
|
17
18
|
dcbEventLogOps: DcbEventLog.operations,
|
|
18
19
|
) => {
|
|
@@ -43,6 +44,7 @@ module Make = (
|
|
|
43
44
|
Callback.handleCommands(
|
|
44
45
|
~tagKeysByEventType,
|
|
45
46
|
~crossPartitionTagKeys,
|
|
47
|
+
~crossPartitionPairs,
|
|
46
48
|
~partitionTag?,
|
|
47
49
|
dcbEventLogOps,
|
|
48
50
|
decodedStream,
|
|
@@ -56,6 +58,7 @@ module Make = (
|
|
|
56
58
|
~publishJsons: Pulumi.Output.t<CommandTopic.publishJsons>,
|
|
57
59
|
~tagKeysByEventType,
|
|
58
60
|
~crossPartitionTagKeys,
|
|
61
|
+
~crossPartitionPairs,
|
|
59
62
|
~partitionTag,
|
|
60
63
|
self,
|
|
61
64
|
_name,
|
|
@@ -70,6 +73,7 @@ module Make = (
|
|
|
70
73
|
let jsonHandler = makeJsonHandler(
|
|
71
74
|
~tagKeysByEventType,
|
|
72
75
|
~crossPartitionTagKeys,
|
|
76
|
+
~crossPartitionPairs,
|
|
73
77
|
~partitionTag,
|
|
74
78
|
dcbEventLogOps,
|
|
75
79
|
)
|
|
@@ -102,6 +106,7 @@ module Make = (
|
|
|
102
106
|
~publishJsons,
|
|
103
107
|
~tagKeysByEventType=Dict.make(),
|
|
104
108
|
~crossPartitionTagKeys=[],
|
|
109
|
+
~crossPartitionPairs=[],
|
|
105
110
|
~partitionTag=?,
|
|
106
111
|
~runtime as _=?,
|
|
107
112
|
~opts=?,
|
|
@@ -114,6 +119,7 @@ module Make = (
|
|
|
114
119
|
~publishJsons,
|
|
115
120
|
~tagKeysByEventType,
|
|
116
121
|
~crossPartitionTagKeys,
|
|
122
|
+
~crossPartitionPairs,
|
|
117
123
|
~partitionTag,
|
|
118
124
|
...
|
|
119
125
|
),
|
|
@@ -19,7 +19,7 @@ let log = Logger$ReventlessCore.fromEnv();
|
|
|
19
19
|
function Make(Spec) {
|
|
20
20
|
return Decision => {
|
|
21
21
|
let Callback = StateChangeSlice_Callback$ReventlessCore.Make(Spec)(Decision);
|
|
22
|
-
let makeJsonHandler = (tagKeysByEventType, crossPartitionTagKeys, partitionTag, dcbEventLogOps) => (stream => {
|
|
22
|
+
let makeJsonHandler = (tagKeysByEventType, crossPartitionTagKeys, crossPartitionPairs, partitionTag, dcbEventLogOps) => (stream => {
|
|
23
23
|
let decodedStream = Stream$1.flatMap(Stream.mapEffect(stream, param => {
|
|
24
24
|
let reference = param.reference;
|
|
25
25
|
let json = param.command;
|
|
@@ -45,16 +45,17 @@ function Make(Spec) {
|
|
|
45
45
|
return Stream$1.empty;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
return Callback.handleCommands(tagKeysByEventType, crossPartitionTagKeys, partitionTag, dcbEventLogOps, decodedStream);
|
|
48
|
+
return Callback.handleCommands(tagKeysByEventType, crossPartitionTagKeys, crossPartitionPairs, partitionTag, dcbEventLogOps, decodedStream);
|
|
49
49
|
});
|
|
50
|
-
let make = (dcbEventLog, publishJsons, tagKeysByEventTypeOpt, crossPartitionTagKeysOpt, partitionTag, param, opts) => {
|
|
50
|
+
let make = (dcbEventLog, publishJsons, tagKeysByEventTypeOpt, crossPartitionTagKeysOpt, crossPartitionPairsOpt, partitionTag, param, opts) => {
|
|
51
51
|
let tagKeysByEventType = tagKeysByEventTypeOpt !== undefined ? tagKeysByEventTypeOpt : ({});
|
|
52
52
|
let crossPartitionTagKeys = crossPartitionTagKeysOpt !== undefined ? crossPartitionTagKeysOpt : [];
|
|
53
|
+
let crossPartitionPairs = crossPartitionPairsOpt !== undefined ? crossPartitionPairsOpt : [];
|
|
53
54
|
return Component$ReventlessCore.make(ComponentType$ReventlessCore.toString(StateChangeSlice$ReventlessCore.componentType), Spec.name, (extra, extra$1) => {
|
|
54
55
|
let commandSchema = Spec.commandSchema;
|
|
55
56
|
let commandTypeNames = CommandTopic$ReventlessCore.extractTypeNamesFromSchema(commandSchema);
|
|
56
57
|
Component$ReventlessCore.operations(dcbEventLog).apply(dcbEventLogOps => {
|
|
57
|
-
let jsonHandler = makeJsonHandler(tagKeysByEventType, crossPartitionTagKeys, partitionTag, dcbEventLogOps);
|
|
58
|
+
let jsonHandler = makeJsonHandler(tagKeysByEventType, crossPartitionTagKeys, crossPartitionPairs, partitionTag, dcbEventLogOps);
|
|
58
59
|
CommandTopic$ReventlessCore.registerHandler(commandSchema, jsonHandler, commandTypeNames);
|
|
59
60
|
});
|
|
60
61
|
Component$ReventlessCore.setOperations(extra, publishJsons.apply(publishJsons => ({
|