@reventlessdev/reventless-core 3.0.0-alpha.326 → 3.0.0-alpha.327
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 +8 -0
- package/package.json +5 -5
- package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res.mjs +5 -5
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res.mjs +2 -2
- package/src/admin/Platform_Admin_Callback.res.mjs +1 -1
- package/src/components/Aggregate/Aggregate_Callback.res +88 -18
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +53 -32
- package/src/components/AutomationSlice/AutomationSlice_Builder.res.mjs +1 -1
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +8 -0
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +16 -12
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +47 -6
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +41 -4
- package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +1 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res +9 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +7 -6
- package/src/components/CommandTopic/CommandTopic_Operations.res +2 -0
- package/src/components/CommandTopic/CommandTopic_Operations.res.mjs +2 -2
- package/src/components/Counter/Counter_Callback.res.mjs +3 -3
- package/src/components/Counter/Counter_Operations.res.mjs +4 -4
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +3 -3
- package/src/components/EventLog/EventLog_Operations.res +1 -0
- package/src/components/EventLog/EventLog_Operations.res.mjs +3 -3
- package/src/components/EventMapper/EventMapper_Callback.res +4 -0
- package/src/components/EventMapper/EventMapper_Callback.res.mjs +13 -12
- package/src/components/EventTopic/EventTopic_Operations.res +2 -0
- package/src/components/EventTopic/EventTopic_Operations.res.mjs +2 -2
- package/src/components/Extension/Extension_Operations.res +4 -0
- package/src/components/Extension/Extension_Operations.res.mjs +8 -8
- package/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs +2 -2
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +2 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res.mjs +9 -8
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +1 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Webhook.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +8 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +10 -10
- package/src/components/ReadModel/ReadModel_Callback.res +1 -0
- package/src/components/ReadModel/ReadModel_Callback.res.mjs +1 -1
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +2 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +6 -6
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +36 -7
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +38 -20
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +2 -0
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +2 -2
- package/src/components/StateViewSlice/StateViewSlice_Callback.res +6 -0
- package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +3 -2
- package/src/plugin/component/Plugin_Callback.res.mjs +2 -2
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +6 -6
- package/src/util/CommandPublisher.res.mjs +9 -9
- package/src/util/EffectLogger.res +85 -17
- package/src/util/EffectLogger.res.mjs +63 -12
- package/src/util/FTPHandler.res.mjs +6 -6
- package/src/util/ScheduleOps.res.mjs +4 -4
- package/src/util/Util_AdapterRuntime.res.mjs +2 -2
- package/src/util/Util_Promise.res.mjs +1 -1
- package/src/util/Util_QueryDbRuntime.res.mjs +1 -1
- package/src/util/Validation.res.mjs +1 -1
- package/tests/commandgenerator/OwnerStampingTest.res +65 -0
- package/tests/commandgenerator/OwnerStampingTest.res.mjs +62 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res +25 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +28 -0
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +4 -4
- package/tests/logger/ComponentLineIdsTest.res +97 -0
- package/tests/logger/ComponentLineIdsTest.res.mjs +118 -0
- package/tests/logger/LogFormatTest.res.mjs +5 -5
- package/tests/logger/LoggerSinkTest.res.mjs +3 -3
|
@@ -183,7 +183,7 @@ function Make(Spec) {
|
|
|
183
183
|
};
|
|
184
184
|
} catch (raw_exn) {
|
|
185
185
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
186
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`InboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to encode command: ` + messageOf(exn, "unknown")));
|
|
186
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`InboundTranslationSlice(` + Spec.name + `)`, undefined, undefined, `failed to encode command: ` + messageOf(exn, "unknown")));
|
|
187
187
|
return {
|
|
188
188
|
TAG: "Error",
|
|
189
189
|
_0: "failed to encode command"
|
|
@@ -260,7 +260,7 @@ async function serve(slice, secretOfOpt, nowSecondsOpt, request) {
|
|
|
260
260
|
return respond(await slice.refuse(request.body, "InvalidBody", "body is not JSON"));
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`InboundTranslationSlice(` + slice.route.slice + `)`, undefined, `webhook secret ` + signed._0 + ` is not set; refusing every request`));
|
|
263
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`InboundTranslationSlice(` + slice.route.slice + `)`, undefined, undefined, `webhook secret ` + signed._0 + ` is not set; refusing every request`));
|
|
264
264
|
return plain(500, "webhook is not configured");
|
|
265
265
|
}
|
|
266
266
|
|
|
@@ -116,7 +116,7 @@ function Make(RuntimeEnvironment) {
|
|
|
116
116
|
await syncToQueryDb(queryDbOps);
|
|
117
117
|
Stdlib_Promise.$$catch(Callback.phase2(publishJsonsFn, Capabilities.capabilities()).then(() => syncToQueryDb(queryDbOps)), exn => {
|
|
118
118
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
119
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `detached phase 2 error: ` + errMsg));
|
|
119
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, undefined, `detached phase 2 error: ` + errMsg));
|
|
120
120
|
return Promise.resolve();
|
|
121
121
|
});
|
|
122
122
|
}));
|
|
@@ -203,6 +203,7 @@ module Make = (
|
|
|
203
203
|
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
204
204
|
EffectLogger.logError(
|
|
205
205
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
206
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
206
207
|
`retries exhausted for ${id}, and the abandonment command could not be published: ${errMsg}`,
|
|
207
208
|
)->Effect.runSync
|
|
208
209
|
}
|
|
@@ -210,6 +211,7 @@ module Make = (
|
|
|
210
211
|
| exception _ =>
|
|
211
212
|
EffectLogger.logError(
|
|
212
213
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
214
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
213
215
|
`retries exhausted for ${id}, and its item could not be decoded to announce it`,
|
|
214
216
|
)->Effect.runSync
|
|
215
217
|
}
|
|
@@ -278,6 +280,7 @@ module Make = (
|
|
|
278
280
|
| Error(e) =>
|
|
279
281
|
EffectLogger.logError(
|
|
280
282
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
283
|
+
~ids=?source->Option.map(EffectLogger.idsOfSource),
|
|
281
284
|
`a work item was not stored: ${e->Reventless.Pii.errorMessage}`,
|
|
282
285
|
)->Effect.runSync
|
|
283
286
|
| Ok(stored) =>
|
|
@@ -345,6 +348,7 @@ module Make = (
|
|
|
345
348
|
| Error(#Gone(field)) =>
|
|
346
349
|
EffectLogger.logInfo(
|
|
347
350
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
351
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
348
352
|
`${id}: its ${field} was erased; nothing to do`,
|
|
349
353
|
)->Effect.runSync
|
|
350
354
|
todoItems->Dict.set(id, {...row, status: Completed, completedAt: now()})
|
|
@@ -352,6 +356,7 @@ module Make = (
|
|
|
352
356
|
| Error(#Unopened(why)) =>
|
|
353
357
|
EffectLogger.logError(
|
|
354
358
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
359
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
355
360
|
`${id}: its work item does not open: ${why}`,
|
|
356
361
|
)->Effect.runSync
|
|
357
362
|
let updated = row->afterFailedAttempt(~lastError=why)
|
|
@@ -367,6 +372,7 @@ module Make = (
|
|
|
367
372
|
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
368
373
|
EffectLogger.logError(
|
|
369
374
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
375
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
370
376
|
`failed to decode outboundItem: ${errMsg}`,
|
|
371
377
|
)->Effect.runSync
|
|
372
378
|
None
|
|
@@ -399,6 +405,7 @@ module Make = (
|
|
|
399
405
|
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
400
406
|
EffectLogger.logError(
|
|
401
407
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
408
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
402
409
|
`failed to encode inbound command: ${errMsg}`,
|
|
403
410
|
)->Effect.runSync
|
|
404
411
|
None
|
|
@@ -420,6 +427,7 @@ module Make = (
|
|
|
420
427
|
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown")
|
|
421
428
|
EffectLogger.logError(
|
|
422
429
|
~comp=`OutboundTranslationSlice(${Spec.name})`,
|
|
430
|
+
~ids=?row.source->Option.map(EffectLogger.idsOfSource),
|
|
423
431
|
`failed to publish command: ${errMsg}`,
|
|
424
432
|
)->Effect.runSync
|
|
425
433
|
let updated = row->afterFailedAttempt(~lastError=errMsg)
|
|
@@ -73,7 +73,7 @@ function Make(Spec) {
|
|
|
73
73
|
try {
|
|
74
74
|
item = Util_Sury$Reventless.fromJson(row.item, Spec.outboundItemSchema);
|
|
75
75
|
} catch (exn) {
|
|
76
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `retries exhausted for ` + id + `, and its item could not be decoded to announce it`));
|
|
76
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `retries exhausted for ` + id + `, and its item could not be decoded to announce it`));
|
|
77
77
|
}
|
|
78
78
|
let match = Translation.onExhausted(id, item, row.lastError);
|
|
79
79
|
if (match === undefined) {
|
|
@@ -92,7 +92,7 @@ function Make(Spec) {
|
|
|
92
92
|
} catch (raw_exn) {
|
|
93
93
|
let exn$1 = Primitive_exceptions.internalToException(raw_exn);
|
|
94
94
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$1), Stdlib_JsExn.message), "unknown");
|
|
95
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `retries exhausted for ` + id + `, and the abandonment command could not be published: ` + errMsg));
|
|
95
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `retries exhausted for ` + id + `, and the abandonment command could not be published: ` + errMsg));
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
let personalFields = Pii$Reventless.recordFields(Spec.outboundItemSchema);
|
|
@@ -110,12 +110,12 @@ function Make(Spec) {
|
|
|
110
110
|
}
|
|
111
111
|
let why = fingerprint._0._0;
|
|
112
112
|
if (Pii$Reventless.Provider.isRequired()) {
|
|
113
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `a work item was not stored: its row id cannot be fingerprinted (` + why + `)`));
|
|
113
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, undefined, `a work item was not stored: its row id cannot be fingerprinted (` + why + `)`));
|
|
114
114
|
return;
|
|
115
115
|
} else {
|
|
116
116
|
if (!warnedUnkeyed.contents) {
|
|
117
117
|
warnedUnkeyed.contents = true;
|
|
118
|
-
Effect.runSync(EffectLogger$ReventlessCore.logWarn(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `work items carrying personal data are keyed in the clear: no key to fingerprint them with (` + why + `)`));
|
|
118
|
+
Effect.runSync(EffectLogger$ReventlessCore.logWarn(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, undefined, `work items carrying personal data are keyed in the clear: no key to fingerprint them with (` + why + `)`));
|
|
119
119
|
}
|
|
120
120
|
return key;
|
|
121
121
|
}
|
|
@@ -150,7 +150,7 @@ function Make(Spec) {
|
|
|
150
150
|
};
|
|
151
151
|
todoItems[id] = row;
|
|
152
152
|
} else {
|
|
153
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `a work item was not stored: ` + Pii$Reventless.errorMessage(stored._0)));
|
|
153
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(source, EffectLogger$ReventlessCore.idsOfSource), `a work item was not stored: ` + Pii$Reventless.errorMessage(stored._0)));
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -222,13 +222,13 @@ function Make(Spec) {
|
|
|
222
222
|
} catch (raw_exn) {
|
|
223
223
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
224
224
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown");
|
|
225
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to decode outboundItem: ` + errMsg));
|
|
225
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to decode outboundItem: ` + errMsg));
|
|
226
226
|
item = undefined;
|
|
227
227
|
}
|
|
228
228
|
} else {
|
|
229
229
|
let match = opened._0;
|
|
230
230
|
if (match.NAME === "Gone") {
|
|
231
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, id + `: its ` + match.VAL + ` was erased; nothing to do`));
|
|
231
|
+
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`));
|
|
232
232
|
let newrecord = {...row};
|
|
233
233
|
newrecord.completedAt = new Date().toISOString();
|
|
234
234
|
newrecord.status = "Completed";
|
|
@@ -236,7 +236,7 @@ function Make(Spec) {
|
|
|
236
236
|
item = undefined;
|
|
237
237
|
} else {
|
|
238
238
|
let why = match.VAL;
|
|
239
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, id + `: its work item does not open: ` + why));
|
|
239
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), id + `: its work item does not open: ` + why));
|
|
240
240
|
let updated = afterFailedAttempt(row, why);
|
|
241
241
|
todoItems[id] = updated;
|
|
242
242
|
if (updated.status === "Abandoned") {
|
|
@@ -272,7 +272,7 @@ function Make(Spec) {
|
|
|
272
272
|
} catch (raw_exn$2) {
|
|
273
273
|
let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
|
|
274
274
|
let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
|
|
275
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to encode inbound command: ` + errMsg$1));
|
|
275
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to encode inbound command: ` + errMsg$1));
|
|
276
276
|
commandJson = undefined;
|
|
277
277
|
}
|
|
278
278
|
if (commandJson !== undefined) {
|
|
@@ -293,7 +293,7 @@ function Make(Spec) {
|
|
|
293
293
|
} catch (raw_exn$3) {
|
|
294
294
|
let exn$3 = Primitive_exceptions.internalToException(raw_exn$3);
|
|
295
295
|
let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$3), Stdlib_JsExn.message), "unknown");
|
|
296
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, `failed to publish command: ` + errMsg$2));
|
|
296
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(`OutboundTranslationSlice(` + Spec.name + `)`, undefined, Stdlib_Option.map(row.source, EffectLogger$ReventlessCore.idsOfSource), `failed to publish command: ` + errMsg$2));
|
|
297
297
|
let updated$1 = afterFailedAttempt(row, errMsg$2);
|
|
298
298
|
todoItems[id] = updated$1;
|
|
299
299
|
if (updated$1.status === "Abandoned") {
|
|
@@ -31,6 +31,7 @@ module Make = (
|
|
|
31
31
|
let idxStr = (idx + 1)->Int.toString
|
|
32
32
|
EffectLogger.logInfo(
|
|
33
33
|
~comp,
|
|
34
|
+
~ids=EffectLogger.idsOf(context.meta, ~entityId=context.id, ~entityType=sourceName),
|
|
34
35
|
~detail=json,
|
|
35
36
|
`handling event ${idxStr}/${total} from ${sourceName}: ${LogFormat.eventDetail(
|
|
36
37
|
json,
|
|
@@ -30,7 +30,7 @@ function Make(ReadModelSpec) {
|
|
|
30
30
|
let actions = EventProjector.map(sourceName, json);
|
|
31
31
|
let actionsStr = LogFormat$ReventlessCore.actionNames(actions);
|
|
32
32
|
let idxStr = (idx + 1 | 0).toString();
|
|
33
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, json, `handling event ` + idxStr + `/` + total + ` from ` + sourceName + `: ` + LogFormat$ReventlessCore.eventDetail(json) + ` actions:` + actionsStr));
|
|
33
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, json, EffectLogger$ReventlessCore.idsOf(context.id, sourceName, context.meta), `handling event ` + idxStr + `/` + total + ` from ` + sourceName + `: ` + LogFormat$ReventlessCore.eventDetail(json) + ` actions:` + actionsStr));
|
|
34
34
|
let sources = [ViewChange$ReventlessCore.sourceOf(context.meta, context.id, sourceName, undefined)];
|
|
35
35
|
return actions.map(action => [
|
|
36
36
|
Projection$ReventlessCore.rewriteAction(action, context.meta.time, ReadModelSpec.stateSchema),
|
|
@@ -72,6 +72,7 @@ module Make = (Spec: Spec): T => {
|
|
|
72
72
|
let sourceName = SideEffect.Source.name
|
|
73
73
|
EffectLogger.logInfo(
|
|
74
74
|
~comp="SideEffectHandler",
|
|
75
|
+
~ids=EffectLogger.idsOf(eventMeta),
|
|
75
76
|
`eventsHandler: handling event from source ${sourceName}: ${LogFormat.event'JsonToLogMessage(
|
|
76
77
|
eventJson',
|
|
77
78
|
)}`,
|
|
@@ -106,6 +107,7 @@ module Make = (Spec: Spec): T => {
|
|
|
106
107
|
| _ =>
|
|
107
108
|
EffectLogger.logError(
|
|
108
109
|
~comp="SideEffectHandler",
|
|
110
|
+
~ids=EffectLogger.idsOf(eventMeta),
|
|
109
111
|
`eventHandler: Invalid event ${eventJson'->JSON.stringify}`,
|
|
110
112
|
)
|
|
111
113
|
}
|
|
@@ -28,7 +28,7 @@ function Make(Spec) {
|
|
|
28
28
|
} catch (raw_err) {
|
|
29
29
|
let err = Primitive_exceptions.internalToException(raw_err);
|
|
30
30
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(err), Stdlib_JsExn.message), "unknown");
|
|
31
|
-
Effect$1.runSync(EffectLogger$ReventlessCore.logError("SideEffects", undefined, `map: Couldn't decode meta: ` + errMsg));
|
|
31
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("SideEffects", undefined, undefined, `map: Couldn't decode meta: ` + errMsg));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
if (eventMeta !== undefined) {
|
|
@@ -47,7 +47,7 @@ function Make(Spec) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
Effect$1.runSync(EffectLogger$ReventlessCore.logError("SideEffects", undefined, "map: Invalid JSON object"));
|
|
50
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("SideEffects", undefined, undefined, "map: Invalid JSON object"));
|
|
51
51
|
});
|
|
52
52
|
let handleJsonEvents = stream => Stream.runDrain(Stream.mapEffect(stream, eventJson$p => {
|
|
53
53
|
let match = findSideEffect(sideEffectsWithTags, eventJson$p);
|
|
@@ -58,7 +58,7 @@ function Make(Spec) {
|
|
|
58
58
|
let eventMeta = match[1];
|
|
59
59
|
let eventObj = match[0];
|
|
60
60
|
let sourceName = sideEffect.Source.name;
|
|
61
|
-
return Effect$1.zipRight(EffectLogger$ReventlessCore.logInfo("SideEffectHandler", undefined, `eventsHandler: handling event from source ` + sourceName + `: ` + LogFormat$ReventlessCore.event$pJsonToLogMessage(eventJson$p)), Effect$1.catchAll(Effect$1.flatMap(Effect.trySync(err => {
|
|
61
|
+
return Effect$1.zipRight(EffectLogger$ReventlessCore.logInfo("SideEffectHandler", undefined, EffectLogger$ReventlessCore.idsOf(undefined, undefined, eventMeta), `eventsHandler: handling event from source ` + sourceName + `: ` + LogFormat$ReventlessCore.event$pJsonToLogMessage(eventJson$p)), Effect$1.catchAll(Effect$1.flatMap(Effect.trySync(err => {
|
|
62
62
|
let errMsg = Util_Error$ReventlessCore.messageFromUnknown(err, "unknown");
|
|
63
63
|
return `SideEffectHandler.eventHandler: Couldn't decode event: ` + JSON.stringify(eventJson$p) + ` ` + errMsg;
|
|
64
64
|
}, () => {
|
|
@@ -78,11 +78,11 @@ function Make(Spec) {
|
|
|
78
78
|
return Effect$1.catchAll(Effect.tryPromise(err => {
|
|
79
79
|
let errMsg = Util_Error$ReventlessCore.messageFromUnknown(err, "unknown");
|
|
80
80
|
return `SideEffect: Error while processing: ` + errMsg;
|
|
81
|
-
}, () => sideEffect.execute(eventId$1, eventMeta, event$1, Spec.queryEngine)), errMsg => EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, errMsg));
|
|
81
|
+
}, () => sideEffect.execute(eventId$1, eventMeta, event$1, Spec.queryEngine)), errMsg => EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, undefined, errMsg));
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, `eventHandler: Invalid event ` + JSON.stringify(eventJson$p));
|
|
85
|
-
}), errMsg => EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, errMsg)));
|
|
84
|
+
return EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, EffectLogger$ReventlessCore.idsOf(undefined, undefined, eventMeta), `eventHandler: Invalid event ` + JSON.stringify(eventJson$p));
|
|
85
|
+
}), errMsg => EffectLogger$ReventlessCore.logError("SideEffectHandler", undefined, undefined, errMsg)));
|
|
86
86
|
}));
|
|
87
87
|
return {
|
|
88
88
|
handleJsonEvents: handleJsonEvents
|
|
@@ -267,6 +267,7 @@ module Make = (
|
|
|
267
267
|
// the fields, so a leading `(id)` would just duplicate it.
|
|
268
268
|
EffectLogger.logInfo(
|
|
269
269
|
~comp,
|
|
270
|
+
~ids=EffectLogger.idsOf(cmdJson.meta),
|
|
270
271
|
~detail=cmdJson.commandJson,
|
|
271
272
|
`handling command: ${cmdJson->LogFormat.cmdDetailNoId}`,
|
|
272
273
|
)->Effect.runSync
|
|
@@ -300,7 +301,11 @@ module Make = (
|
|
|
300
301
|
tags == "" ? types : `${types}{${tags}}`
|
|
301
302
|
})
|
|
302
303
|
->Array.join(" OR ")
|
|
303
|
-
EffectLogger.logInfo(
|
|
304
|
+
EffectLogger.logInfo(
|
|
305
|
+
~comp,
|
|
306
|
+
~ids=EffectLogger.idsOf(cmdJson.meta),
|
|
307
|
+
`query: ${queryDetail}`,
|
|
308
|
+
)->Effect.runSync
|
|
304
309
|
|
|
305
310
|
// Extract the entity ID from the command for use in Accepted outcomes.
|
|
306
311
|
let entityId = switch partitionTag {
|
|
@@ -310,6 +315,12 @@ module Make = (
|
|
|
310
315
|
| Some(Simple(pt)) => Reventless.DcbTag.getPartitionTagValue(query, pt)
|
|
311
316
|
| Some(ByEventType(_)) | None => None
|
|
312
317
|
}
|
|
318
|
+
// The lines of this command name it and, for a simple partition, the entity it decides on:
|
|
319
|
+
// the partition tag's key and value, as a row change names a DCB event's entity.
|
|
320
|
+
let ids = switch partitionTag {
|
|
321
|
+
| Some(Simple(pt)) => EffectLogger.idsOf(cmdJson.meta, ~entityId?, ~entityType=pt.key)
|
|
322
|
+
| _ => EffectLogger.idsOf(cmdJson.meta)
|
|
323
|
+
}
|
|
313
324
|
|
|
314
325
|
// The owner fields of a read event, when it lies in this command's own
|
|
315
326
|
// partition. A cross-partition read (a catalog product) never says who owns
|
|
@@ -451,6 +462,7 @@ module Make = (
|
|
|
451
462
|
}
|
|
452
463
|
EffectLogger.logInfo(
|
|
453
464
|
~comp,
|
|
465
|
+
~ids,
|
|
454
466
|
`read${cacheHit ? " (cached, delta)" : ""}: ${reads
|
|
455
467
|
->Array.length
|
|
456
468
|
->Int.toString} event(s)${reads->Array.length == 0
|
|
@@ -464,6 +476,7 @@ module Make = (
|
|
|
464
476
|
// how long the entity has been in use.
|
|
465
477
|
EffectLogger.logDebug(
|
|
466
478
|
~comp,
|
|
479
|
+
~ids,
|
|
467
480
|
`deciding: id=${entityId->Option.getOr("-")} head=${headPosition->Option.getOr(
|
|
468
481
|
"-",
|
|
469
482
|
)} cmd=${cmdJson->LogFormat.cmdName}`,
|
|
@@ -476,6 +489,7 @@ module Make = (
|
|
|
476
489
|
CommandTopic_Helpers.reportAccepted(
|
|
477
490
|
~component=Spec.name,
|
|
478
491
|
~correlationId=cmdJson.meta.correlationId,
|
|
492
|
+
~causationId=?cmdJson.meta.causationId,
|
|
479
493
|
cmdJson.meta.msgId,
|
|
480
494
|
switch entityId {
|
|
481
495
|
| Some(eid) => {entityId: eid, eventCount: 0}
|
|
@@ -484,6 +498,7 @@ module Make = (
|
|
|
484
498
|
)
|
|
485
499
|
EffectLogger.logInfo(
|
|
486
500
|
~comp,
|
|
501
|
+
~ids,
|
|
487
502
|
`repeat dropped: ${cmdJson->LogFormat.cmdName} msgId=${cmdJson.meta.msgId} already caused events in id=${entityId->Option.getOr(
|
|
488
503
|
"-",
|
|
489
504
|
)}`,
|
|
@@ -494,6 +509,7 @@ module Make = (
|
|
|
494
509
|
CommandTopic_Helpers.reportRejected(
|
|
495
510
|
~component=Spec.name,
|
|
496
511
|
~correlationId=cmdJson.meta.correlationId,
|
|
512
|
+
~causationId=?cmdJson.meta.causationId,
|
|
497
513
|
~cause=AccessRefusal,
|
|
498
514
|
cmdJson.meta.msgId,
|
|
499
515
|
rejected,
|
|
@@ -501,7 +517,9 @@ module Make = (
|
|
|
501
517
|
let line = `refused: ${rejected.errorDetail} id=${entityId->Option.getOr("-")}`
|
|
502
518
|
|
|
503
519
|
(
|
|
504
|
-
isDefect
|
|
520
|
+
isDefect
|
|
521
|
+
? EffectLogger.logError(~comp, ~ids, line)
|
|
522
|
+
: EffectLogger.logWarn(~comp, ~ids, line)
|
|
505
523
|
)->Effect.map(_ => Ok("rejected"))
|
|
506
524
|
| None =>
|
|
507
525
|
switch Decision.decide(state, command'.command) {
|
|
@@ -511,13 +529,14 @@ module Make = (
|
|
|
511
529
|
CommandTopic_Helpers.reportAccepted(
|
|
512
530
|
~component=Spec.name,
|
|
513
531
|
~correlationId=cmdJson.meta.correlationId,
|
|
532
|
+
~causationId=?cmdJson.meta.causationId,
|
|
514
533
|
cmdJson.meta.msgId,
|
|
515
534
|
switch entityId {
|
|
516
535
|
| Some(eid) => {entityId: eid, eventCount: 0}
|
|
517
536
|
| None => {eventCount: 0}
|
|
518
537
|
},
|
|
519
538
|
)
|
|
520
|
-
EffectLogger.logInfo(~comp, "no events produced")->Effect.map(_ => Ok("ok"))
|
|
539
|
+
EffectLogger.logInfo(~comp, ~ids, "no events produced")->Effect.map(_ => Ok("ok"))
|
|
521
540
|
| Ok(newEvents) =>
|
|
522
541
|
let encoded =
|
|
523
542
|
newEvents->Array.map(
|
|
@@ -533,6 +552,7 @@ module Make = (
|
|
|
533
552
|
CommandTopic_Helpers.reportRejected(
|
|
534
553
|
~component=Spec.name,
|
|
535
554
|
~correlationId=cmdJson.meta.correlationId,
|
|
555
|
+
~causationId=?cmdJson.meta.causationId,
|
|
536
556
|
~cause=InfrastructureFailure,
|
|
537
557
|
cmdJson.meta.msgId,
|
|
538
558
|
{
|
|
@@ -540,7 +560,7 @@ module Make = (
|
|
|
540
560
|
errorDetail: detail,
|
|
541
561
|
},
|
|
542
562
|
)
|
|
543
|
-
EffectLogger.logError(~comp, `append refused: ${detail}`)->Effect.map(
|
|
563
|
+
EffectLogger.logError(~comp, ~ids, `append refused: ${detail}`)->Effect.map(
|
|
544
564
|
_ => Error(detail),
|
|
545
565
|
)
|
|
546
566
|
| Ok(rawEvents) =>
|
|
@@ -564,6 +584,7 @@ module Make = (
|
|
|
564
584
|
}
|
|
565
585
|
EffectLogger.logInfo(
|
|
566
586
|
~comp,
|
|
587
|
+
~ids,
|
|
567
588
|
~detail=eventJsons,
|
|
568
589
|
`produced ${eventCount} event(s): [${eventDetails}]`,
|
|
569
590
|
)
|
|
@@ -581,15 +602,18 @@ module Make = (
|
|
|
581
602
|
CommandTopic_Helpers.reportAccepted(
|
|
582
603
|
~component=Spec.name,
|
|
583
604
|
~correlationId=cmdJson.meta.correlationId,
|
|
605
|
+
~causationId=?cmdJson.meta.causationId,
|
|
584
606
|
cmdJson.meta.msgId,
|
|
585
607
|
switch entityId {
|
|
586
608
|
| Some(eid) => {entityId: eid, eventCount: rawEvents->Array.length}
|
|
587
609
|
| None => {eventCount: rawEvents->Array.length}
|
|
588
610
|
},
|
|
589
611
|
)
|
|
590
|
-
EffectLogger.logInfo(
|
|
591
|
-
|
|
592
|
-
|
|
612
|
+
EffectLogger.logInfo(
|
|
613
|
+
~comp,
|
|
614
|
+
~ids,
|
|
615
|
+
`append: ${eventCount} event(s)`,
|
|
616
|
+
)->Effect.map(_ => Ok("ok"))
|
|
593
617
|
| Error(err) =>
|
|
594
618
|
// Typed classification (was substring-matching the error string,
|
|
595
619
|
// which disagreed with the backends' casing).
|
|
@@ -613,6 +637,7 @@ module Make = (
|
|
|
613
637
|
Metrics.emitCount(~metric="AppendRetry", ~slice=Spec.name)
|
|
614
638
|
EffectLogger.logWarn(
|
|
615
639
|
~comp,
|
|
640
|
+
~ids,
|
|
616
641
|
`append failed (retrying ${(maxRetries - retries + 1)
|
|
617
642
|
->Int.toString}/${maxRetries->Int.toString}): ${errDetail}`,
|
|
618
643
|
)->Effect.flatMap(_ => attempt(~retries=retries - 1))
|
|
@@ -633,12 +658,14 @@ module Make = (
|
|
|
633
658
|
CommandTopic_Helpers.reportRejected(
|
|
634
659
|
~component=Spec.name,
|
|
635
660
|
~correlationId=cmdJson.meta.correlationId,
|
|
661
|
+
~causationId=?cmdJson.meta.causationId,
|
|
636
662
|
~cause=InfrastructureFailure,
|
|
637
663
|
cmdJson.meta.msgId,
|
|
638
664
|
{errorCode, errorDetail: errDetail},
|
|
639
665
|
)
|
|
640
666
|
EffectLogger.logError(
|
|
641
667
|
~comp,
|
|
668
|
+
~ids,
|
|
642
669
|
`append failed, retries exhausted: ${errDetail}`,
|
|
643
670
|
)->Effect.map(_ => Error(errDetail))
|
|
644
671
|
}
|
|
@@ -659,12 +686,14 @@ module Make = (
|
|
|
659
686
|
CommandTopic_Helpers.reportRejected(
|
|
660
687
|
~component=Spec.name,
|
|
661
688
|
~correlationId=cmdJson.meta.correlationId,
|
|
689
|
+
~causationId=?cmdJson.meta.causationId,
|
|
662
690
|
~cause=DomainRejection,
|
|
663
691
|
cmdJson.meta.msgId,
|
|
664
692
|
{errorCode, errorDetail},
|
|
665
693
|
)
|
|
666
694
|
EffectLogger.logError(
|
|
667
695
|
~comp,
|
|
696
|
+
~ids,
|
|
668
697
|
`decide rejected: ${errorCode} ${errorDetail}`,
|
|
669
698
|
)->Effect.map(_ => Ok("rejected"))
|
|
670
699
|
}
|
|
@@ -150,7 +150,7 @@ function Make(Spec) {
|
|
|
150
150
|
let resetCache = () => Lru$ReventlessCore.clear(projectionCache);
|
|
151
151
|
let handleSingleCommand = (tagKeysByEventType, crossPartitionTagKeys, payloadTagKeys, partitionTag, dcbEventLog, command$p) => {
|
|
152
152
|
let cmdJson = Message$ReventlessCore.commandJsonOfCommand$p(Id$Reventless.$$String.toString, Spec.commandSchema, command$p);
|
|
153
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, cmdJson.commandJson, `handling command: ` + LogFormat$ReventlessCore.cmdDetailNoId(cmdJson)));
|
|
153
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, cmdJson.commandJson, EffectLogger$ReventlessCore.idsOf(undefined, undefined, cmdJson.meta), `handling command: ` + LogFormat$ReventlessCore.cmdDetailNoId(cmdJson)));
|
|
154
154
|
let asksForRepeat = Message$ReventlessCore.hasStableMsgId(command$p.meta);
|
|
155
155
|
let query = DcbTag$Reventless.buildQueryFromCommand(asksForRepeat ? queryEventTypesWithOwn : queryEventTypes, Spec.commandSchema, command$p.command, tagKeysByEventType, crossPartitionTagKeys, payloadTagKeys);
|
|
156
156
|
let queryDetail = query.map(qi => {
|
|
@@ -164,7 +164,7 @@ function Make(Spec) {
|
|
|
164
164
|
return types + `{` + tags + `}`;
|
|
165
165
|
}
|
|
166
166
|
}).join(" OR ");
|
|
167
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, undefined, `query: ` + queryDetail));
|
|
167
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, undefined, EffectLogger$ReventlessCore.idsOf(undefined, undefined, cmdJson.meta), `query: ` + queryDetail));
|
|
168
168
|
let entityId;
|
|
169
169
|
if (partitionTag !== undefined) {
|
|
170
170
|
switch (partitionTag.TAG) {
|
|
@@ -182,6 +182,24 @@ function Make(Spec) {
|
|
|
182
182
|
} else {
|
|
183
183
|
entityId = undefined;
|
|
184
184
|
}
|
|
185
|
+
let ids;
|
|
186
|
+
let exit = 0;
|
|
187
|
+
if (partitionTag !== undefined) {
|
|
188
|
+
switch (partitionTag.TAG) {
|
|
189
|
+
case "Simple" :
|
|
190
|
+
ids = EffectLogger$ReventlessCore.idsOf(entityId, partitionTag._0.key, cmdJson.meta);
|
|
191
|
+
break;
|
|
192
|
+
case "Composite" :
|
|
193
|
+
case "ByEventType" :
|
|
194
|
+
exit = 1;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
exit = 1;
|
|
199
|
+
}
|
|
200
|
+
if (exit === 1) {
|
|
201
|
+
ids = EffectLogger$ReventlessCore.idsOf(undefined, undefined, cmdJson.meta);
|
|
202
|
+
}
|
|
185
203
|
let ownerFieldsOf = raw => {
|
|
186
204
|
if (partitionTag !== undefined) {
|
|
187
205
|
if (entityId !== undefined) {
|
|
@@ -282,7 +300,7 @@ function Make(Spec) {
|
|
|
282
300
|
if (cacheHit && retries === 3) {
|
|
283
301
|
Metrics$ReventlessCore.emitCount("DcbDecisionModelDeltaEventCount", Spec.name, reads.length);
|
|
284
302
|
}
|
|
285
|
-
return EffectLogger$ReventlessCore.logInfo(comp, undefined, `read` + (
|
|
303
|
+
return EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `read` + (
|
|
286
304
|
cacheHit ? " (cached, delta)" : ""
|
|
287
305
|
) + `: ` + reads.length.toString() + ` event(s)` + (
|
|
288
306
|
reads.length === 0 ? "" : ` [` + reads.join(", ") + `]`
|
|
@@ -292,16 +310,16 @@ function Make(Spec) {
|
|
|
292
310
|
let owners = param[3];
|
|
293
311
|
let headPosition = param[1];
|
|
294
312
|
let state = param[0];
|
|
295
|
-
return Effect.flatMap(EffectLogger$ReventlessCore.logDebug(comp, undefined, `deciding: id=` + Stdlib_Option.getOr(entityId, "-") + ` head=` + Stdlib_Option.getOr(headPosition, "-") + ` cmd=` + LogFormat$ReventlessCore.cmdName(cmdJson)), () => {
|
|
313
|
+
return Effect.flatMap(EffectLogger$ReventlessCore.logDebug(comp, undefined, ids, `deciding: id=` + Stdlib_Option.getOr(entityId, "-") + ` head=` + Stdlib_Option.getOr(headPosition, "-") + ` cmd=` + LogFormat$ReventlessCore.cmdName(cmdJson)), () => {
|
|
296
314
|
let match = ownershipRefusal(owners);
|
|
297
315
|
if (repeated) {
|
|
298
|
-
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
316
|
+
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
299
317
|
entityId: entityId,
|
|
300
318
|
eventCount: 0
|
|
301
319
|
}) : ({
|
|
302
320
|
eventCount: 0
|
|
303
321
|
}));
|
|
304
|
-
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, `repeat dropped: ` + LogFormat$ReventlessCore.cmdName(cmdJson) + ` msgId=` + cmdJson.meta.msgId + ` already caused events in id=` + Stdlib_Option.getOr(entityId, "-")), () => ({
|
|
322
|
+
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `repeat dropped: ` + LogFormat$ReventlessCore.cmdName(cmdJson) + ` msgId=` + cmdJson.meta.msgId + ` already caused events in id=` + Stdlib_Option.getOr(entityId, "-")), () => ({
|
|
305
323
|
TAG: "Ok",
|
|
306
324
|
_0: "ok"
|
|
307
325
|
}));
|
|
@@ -313,9 +331,9 @@ function Make(Spec) {
|
|
|
313
331
|
headPosition,
|
|
314
332
|
owners
|
|
315
333
|
]);
|
|
316
|
-
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "AccessRefusal", cmdJson.meta.correlationId, cmdJson.meta.msgId, rejected);
|
|
334
|
+
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "AccessRefusal", cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, rejected);
|
|
317
335
|
let line = `refused: ` + rejected.errorDetail + ` id=` + Stdlib_Option.getOr(entityId, "-");
|
|
318
|
-
return Effect.map(match.isDefect ? EffectLogger$ReventlessCore.logError(comp, undefined, line) : EffectLogger$ReventlessCore.logWarn(comp, undefined, line), () => ({
|
|
336
|
+
return Effect.map(match.isDefect ? EffectLogger$ReventlessCore.logError(comp, undefined, ids, line) : EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, line), () => ({
|
|
319
337
|
TAG: "Ok",
|
|
320
338
|
_0: "rejected"
|
|
321
339
|
}));
|
|
@@ -329,13 +347,13 @@ function Make(Spec) {
|
|
|
329
347
|
headPosition,
|
|
330
348
|
owners
|
|
331
349
|
]);
|
|
332
|
-
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
350
|
+
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
333
351
|
entityId: entityId,
|
|
334
352
|
eventCount: 0
|
|
335
353
|
}) : ({
|
|
336
354
|
eventCount: 0
|
|
337
355
|
}));
|
|
338
|
-
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, "no events produced"), () => ({
|
|
356
|
+
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, "no events produced"), () => ({
|
|
339
357
|
TAG: "Ok",
|
|
340
358
|
_0: "ok"
|
|
341
359
|
}));
|
|
@@ -373,20 +391,20 @@ function Make(Spec) {
|
|
|
373
391
|
query: query,
|
|
374
392
|
after: headPosition
|
|
375
393
|
};
|
|
376
|
-
return Effect.flatMap(Effect.flatMap(EffectLogger$ReventlessCore.logInfo(comp, eventJsons, `produced ` + eventCount + ` event(s): [` + eventDetails + `]`), () => Effect.promise(() => dcbEventLog.append(rawEvents, condition))), appendResult => {
|
|
394
|
+
return Effect.flatMap(Effect.flatMap(EffectLogger$ReventlessCore.logInfo(comp, eventJsons, ids, `produced ` + eventCount + ` event(s): [` + eventDetails + `]`), () => Effect.promise(() => dcbEventLog.append(rawEvents, condition))), appendResult => {
|
|
377
395
|
if (appendResult.TAG === "Ok") {
|
|
378
396
|
cachePut([
|
|
379
397
|
state,
|
|
380
398
|
headPosition,
|
|
381
399
|
owners
|
|
382
400
|
]);
|
|
383
|
-
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
401
|
+
CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, entityId !== undefined ? ({
|
|
384
402
|
entityId: entityId,
|
|
385
403
|
eventCount: rawEvents.length
|
|
386
404
|
}) : ({
|
|
387
405
|
eventCount: rawEvents.length
|
|
388
406
|
}));
|
|
389
|
-
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, `append: ` + eventCount + ` event(s)`), () => ({
|
|
407
|
+
return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `append: ` + eventCount + ` event(s)`), () => ({
|
|
390
408
|
TAG: "Ok",
|
|
391
409
|
_0: "ok"
|
|
392
410
|
}));
|
|
@@ -409,17 +427,17 @@ function Make(Spec) {
|
|
|
409
427
|
owners
|
|
410
428
|
];
|
|
411
429
|
Metrics$ReventlessCore.emitCount("AppendRetry", Spec.name, undefined);
|
|
412
|
-
return Effect.flatMap(EffectLogger$ReventlessCore.logWarn(comp, undefined, `append failed (retrying ` + ((3 - retries | 0) + 1 | 0).toString() + `/` + (3).toString() + `): ` + errDetail), () => attempt(retries - 1 | 0));
|
|
430
|
+
return Effect.flatMap(EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, `append failed (retrying ` + ((3 - retries | 0) + 1 | 0).toString() + `/` + (3).toString() + `): ` + errDetail), () => attempt(retries - 1 | 0));
|
|
413
431
|
} else {
|
|
414
432
|
cacheInvalidate();
|
|
415
433
|
if (errorCode === CommandOutcome$Reventless.code("Conflict")) {
|
|
416
434
|
Metrics$ReventlessCore.emitCount("AppendConflict", Spec.name, undefined);
|
|
417
435
|
}
|
|
418
|
-
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "InfrastructureFailure", cmdJson.meta.correlationId, cmdJson.meta.msgId, {
|
|
436
|
+
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "InfrastructureFailure", cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, {
|
|
419
437
|
errorCode: errorCode,
|
|
420
438
|
errorDetail: errDetail
|
|
421
439
|
});
|
|
422
|
-
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, `append failed, retries exhausted: ` + errDetail), () => ({
|
|
440
|
+
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append failed, retries exhausted: ` + errDetail), () => ({
|
|
423
441
|
TAG: "Error",
|
|
424
442
|
_0: errDetail
|
|
425
443
|
}));
|
|
@@ -432,11 +450,11 @@ function Make(Spec) {
|
|
|
432
450
|
headPosition,
|
|
433
451
|
owners
|
|
434
452
|
]);
|
|
435
|
-
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "InfrastructureFailure", cmdJson.meta.correlationId, cmdJson.meta.msgId, {
|
|
453
|
+
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "InfrastructureFailure", cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, {
|
|
436
454
|
errorCode: CommandOutcome$Reventless.code("AppendFailed"),
|
|
437
455
|
errorDetail: detail
|
|
438
456
|
});
|
|
439
|
-
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, `append refused: ` + detail), () => ({
|
|
457
|
+
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append refused: ` + detail), () => ({
|
|
440
458
|
TAG: "Error",
|
|
441
459
|
_0: detail
|
|
442
460
|
}));
|
|
@@ -452,11 +470,11 @@ function Make(Spec) {
|
|
|
452
470
|
let match$1 = Message$ReventlessCore.splitMessage(errorJson);
|
|
453
471
|
let payloadDict = match$1[1];
|
|
454
472
|
let errorDetail = Object.entries(payloadDict).length === 0 ? "" : JSON.stringify(payloadDict);
|
|
455
|
-
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "DomainRejection", cmdJson.meta.correlationId, cmdJson.meta.msgId, {
|
|
473
|
+
CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "DomainRejection", cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, {
|
|
456
474
|
errorCode: errorCode,
|
|
457
475
|
errorDetail: errorDetail
|
|
458
476
|
});
|
|
459
|
-
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, `decide rejected: ` + errorCode + ` ` + errorDetail), () => ({
|
|
477
|
+
return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `decide rejected: ` + errorCode + ` ` + errorDetail), () => ({
|
|
460
478
|
TAG: "Ok",
|
|
461
479
|
_0: "rejected"
|
|
462
480
|
}));
|
|
@@ -154,6 +154,7 @@ module Make = (
|
|
|
154
154
|
->Option.getOr("unknown")
|
|
155
155
|
EffectLogger.logError(
|
|
156
156
|
~comp,
|
|
157
|
+
~ids=EffectLogger.idsOf(meta),
|
|
157
158
|
`project failed for ${eventType}: ${errMsg}`,
|
|
158
159
|
)->Effect.runSync
|
|
159
160
|
[]
|
|
@@ -171,6 +172,7 @@ module Make = (
|
|
|
171
172
|
}
|
|
172
173
|
EffectLogger.logInfo(
|
|
173
174
|
~comp,
|
|
175
|
+
~ids=EffectLogger.idsOf(meta),
|
|
174
176
|
~detail=eventData,
|
|
175
177
|
`handling event ${idxStr}/${total}: ${LogFormat.bold(
|
|
176
178
|
eventType,
|