@event-driven-io/emmett 0.43.0-beta.19 → 0.43.0-beta.20
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/dist/chunk-zc3tnsvq.js +36 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-C0agmFA7.d.ts → index-B6YAVHH1.d.ts} +1 -1
- package/dist/index.cjs +844 -309
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +277 -51
- package/dist/index.d.ts +276 -52
- package/dist/index.js +827 -311
- package/dist/index.js.map +1 -1
- package/dist/{plugins-CUbnGFPp.js → plugins-DgfqJ5af.js} +1 -1
- package/dist/{plugins-CUbnGFPp.js.map → plugins-DgfqJ5af.js.map} +1 -1
- package/dist/{plugins-DB9xe8AV.cjs → plugins-iXublZYn.cjs} +27 -1
- package/dist/{plugins-DB9xe8AV.cjs.map → plugins-iXublZYn.cjs.map} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-zc3tnsvq.js";
|
|
2
|
+
import { _ as isValidYYYYMMDD, a as IllegalStateError, c as isErrorConstructor, d as assertPositiveNumber, f as assertUnsignedBigInt, g as formatDateToUtcYYYYMMDD, h as isString, i as EmmettError, l as ValidationErrors, m as isNumber, n as ConcurrencyError, o as NotFoundError, p as isBigint, r as ConcurrencyInMemoryDatabaseError, s as ValidationError, t as isPluginConfig, u as assertNotEmptyString, v as parseDateFromUtcYYYYMMDD } from "./plugins-DgfqJ5af.js";
|
|
2
3
|
import { v4, v7 } from "uuid";
|
|
3
4
|
import retry from "async-retry";
|
|
4
|
-
import { MessagingAttributes, ObservabilityScope, noopMeter, noopTracer } from "@event-driven-io/almanac";
|
|
5
|
+
import { MessagingAttributes, ObservabilityScope, noopMeter, noopScope, noopTracer } from "@event-driven-io/almanac";
|
|
6
|
+
|
|
7
|
+
export * from "@event-driven-io/almanac"
|
|
5
8
|
|
|
6
9
|
//#region src/eventStore/afterCommit/afterEventStoreCommitHandler.ts
|
|
7
10
|
async function tryPublishMessagesAfterCommit(messages, options, context) {
|
|
@@ -976,6 +979,356 @@ const getInMemoryDatabase = () => {
|
|
|
976
979
|
} };
|
|
977
980
|
};
|
|
978
981
|
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/observability/attributes.ts
|
|
984
|
+
const EmmettAttributes = {
|
|
985
|
+
scope: { type: "emmett.scope.type" },
|
|
986
|
+
command: {
|
|
987
|
+
type: "emmett.command.type",
|
|
988
|
+
status: "emmett.command.status",
|
|
989
|
+
eventCount: "emmett.command.event_count",
|
|
990
|
+
eventTypes: "emmett.command.event_types"
|
|
991
|
+
},
|
|
992
|
+
stream: {
|
|
993
|
+
name: "emmett.stream.name",
|
|
994
|
+
versionBefore: "emmett.stream.version.before",
|
|
995
|
+
versionAfter: "emmett.stream.version.after"
|
|
996
|
+
},
|
|
997
|
+
eventStore: {
|
|
998
|
+
operation: "emmett.eventstore.operation",
|
|
999
|
+
read: {
|
|
1000
|
+
eventCount: "emmett.eventstore.read.event_count",
|
|
1001
|
+
eventTypes: "emmett.eventstore.read.event_types",
|
|
1002
|
+
status: "emmett.eventstore.read.status"
|
|
1003
|
+
},
|
|
1004
|
+
append: {
|
|
1005
|
+
batchSize: "emmett.eventstore.append.batch_size",
|
|
1006
|
+
status: "emmett.eventstore.append.status"
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
event: { type: "emmett.event.type" },
|
|
1010
|
+
processor: {
|
|
1011
|
+
id: "emmett.processor.id",
|
|
1012
|
+
type: "emmett.processor.type",
|
|
1013
|
+
status: "emmett.processor.status",
|
|
1014
|
+
batchSize: "emmett.processor.batch_size",
|
|
1015
|
+
eventTypes: "emmett.processor.event_types",
|
|
1016
|
+
checkpointBefore: "emmett.processor.checkpoint.before",
|
|
1017
|
+
checkpointAfter: "emmett.processor.checkpoint.after",
|
|
1018
|
+
lagEvents: "emmett.processor.lag_events"
|
|
1019
|
+
},
|
|
1020
|
+
workflow: {
|
|
1021
|
+
id: "emmett.workflow.id",
|
|
1022
|
+
type: "emmett.workflow.type",
|
|
1023
|
+
inputType: "emmett.workflow.input.type",
|
|
1024
|
+
outputs: "emmett.workflow.outputs",
|
|
1025
|
+
outputsCount: "emmett.workflow.outputs.count",
|
|
1026
|
+
streamPosition: "emmett.workflow.stream_position",
|
|
1027
|
+
stateRebuildEventCount: "emmett.workflow.state_rebuild.event_count"
|
|
1028
|
+
},
|
|
1029
|
+
consumer: {
|
|
1030
|
+
batchSize: "emmett.consumer.batch_size",
|
|
1031
|
+
processorCount: "emmett.consumer.processor_count",
|
|
1032
|
+
delivery: { processorId: "emmett.consumer.delivery.processor_id" }
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
const EmmettMetrics = {
|
|
1036
|
+
command: { handlingDuration: "emmett.command.handling.duration" },
|
|
1037
|
+
event: {
|
|
1038
|
+
appendingCount: "emmett.event.appending.count",
|
|
1039
|
+
readingCount: "emmett.event.reading.count"
|
|
1040
|
+
},
|
|
1041
|
+
stream: {
|
|
1042
|
+
readingDuration: "emmett.stream.reading.duration",
|
|
1043
|
+
readingSize: "emmett.stream.reading.size",
|
|
1044
|
+
appendingDuration: "emmett.stream.appending.duration",
|
|
1045
|
+
appendingSize: "emmett.stream.appending.size"
|
|
1046
|
+
},
|
|
1047
|
+
processor: {
|
|
1048
|
+
processingDuration: "emmett.processor.processing.duration",
|
|
1049
|
+
lagEvents: "emmett.processor.lag_events"
|
|
1050
|
+
},
|
|
1051
|
+
workflow: { processingDuration: "emmett.workflow.processing.duration" },
|
|
1052
|
+
consumer: {
|
|
1053
|
+
pollDuration: "emmett.consumer.poll.duration",
|
|
1054
|
+
deliveryDuration: "emmett.consumer.delivery.duration"
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
const ScopeTypes = {
|
|
1058
|
+
command: "command",
|
|
1059
|
+
processor: "processor",
|
|
1060
|
+
reactor: "reactor",
|
|
1061
|
+
projector: "projector",
|
|
1062
|
+
workflow: "workflow",
|
|
1063
|
+
consumer: "consumer"
|
|
1064
|
+
};
|
|
1065
|
+
const MessagingSystemName = "emmett";
|
|
1066
|
+
|
|
1067
|
+
//#endregion
|
|
1068
|
+
//#region src/observability/options.ts
|
|
1069
|
+
const resolveConsumerObservability = (options, parent) => ({
|
|
1070
|
+
tracer: options?.observability?.tracer ?? parent?.observability?.tracer ?? noopTracer(),
|
|
1071
|
+
meter: options?.observability?.meter ?? parent?.observability?.meter ?? noopMeter(),
|
|
1072
|
+
pollTracing: options?.observability?.pollTracing ?? parent?.observability?.pollTracing ?? "off",
|
|
1073
|
+
attributeTarget: options?.observability?.attributeTarget ?? parent?.observability?.attributeTarget ?? "both"
|
|
1074
|
+
});
|
|
1075
|
+
const resolveWorkflowObservability = (options, parent) => ({
|
|
1076
|
+
tracer: options?.observability?.tracer ?? parent?.observability?.tracer ?? noopTracer(),
|
|
1077
|
+
meter: options?.observability?.meter ?? parent?.observability?.meter ?? noopMeter(),
|
|
1078
|
+
propagation: options?.observability?.propagation ?? parent?.observability?.propagation ?? "links",
|
|
1079
|
+
attributeTarget: options?.observability?.attributeTarget ?? parent?.observability?.attributeTarget ?? "both",
|
|
1080
|
+
includeMessagePayloads: options?.observability?.includeMessagePayloads ?? parent?.observability?.includeMessagePayloads ?? false
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region src/observability/tracer.ts
|
|
1085
|
+
const tracer = () => {};
|
|
1086
|
+
const LogLevel = {
|
|
1087
|
+
DISABLED: "DISABLED",
|
|
1088
|
+
INFO: "INFO",
|
|
1089
|
+
LOG: "LOG",
|
|
1090
|
+
WARN: "WARN",
|
|
1091
|
+
ERROR: "ERROR"
|
|
1092
|
+
};
|
|
1093
|
+
const LogStyle = {
|
|
1094
|
+
RAW: "RAW",
|
|
1095
|
+
PRETTY: "PRETTY"
|
|
1096
|
+
};
|
|
1097
|
+
const getEnvVariable = (name) => {
|
|
1098
|
+
try {
|
|
1099
|
+
if (typeof process !== "undefined" && process.env) return process.env[name];
|
|
1100
|
+
return;
|
|
1101
|
+
} catch {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
const shouldLog = (logLevel) => {
|
|
1106
|
+
const definedLogLevel = getEnvVariable("DUMBO_LOG_LEVEL") ?? LogLevel.ERROR;
|
|
1107
|
+
if (definedLogLevel === LogLevel.ERROR && logLevel === LogLevel.ERROR) return true;
|
|
1108
|
+
if (definedLogLevel === LogLevel.WARN && [LogLevel.ERROR, LogLevel.WARN].includes(logLevel)) return true;
|
|
1109
|
+
if (definedLogLevel === LogLevel.LOG && [
|
|
1110
|
+
LogLevel.ERROR,
|
|
1111
|
+
LogLevel.WARN,
|
|
1112
|
+
LogLevel.LOG
|
|
1113
|
+
].includes(logLevel)) return true;
|
|
1114
|
+
if (definedLogLevel === LogLevel.INFO && [
|
|
1115
|
+
LogLevel.ERROR,
|
|
1116
|
+
LogLevel.WARN,
|
|
1117
|
+
LogLevel.LOG,
|
|
1118
|
+
LogLevel.INFO
|
|
1119
|
+
].includes(logLevel)) return true;
|
|
1120
|
+
return false;
|
|
1121
|
+
};
|
|
1122
|
+
const nulloTraceEventRecorder = () => {};
|
|
1123
|
+
const getTraceEventFormatter = (logStyle, serializer) => (event) => {
|
|
1124
|
+
serializer = serializer ?? JSONSerializer.from();
|
|
1125
|
+
switch (logStyle) {
|
|
1126
|
+
case "RAW": return serializer.serialize(event);
|
|
1127
|
+
case "PRETTY": return serializer.serialize(event);
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
const getTraceEventRecorder = (logLevel, logStyle) => {
|
|
1131
|
+
const format = getTraceEventFormatter(logStyle);
|
|
1132
|
+
switch (logLevel) {
|
|
1133
|
+
case "DISABLED": return nulloTraceEventRecorder;
|
|
1134
|
+
case "INFO": return (event) => console.info(format(event));
|
|
1135
|
+
case "LOG": return (event) => console.log(format(event));
|
|
1136
|
+
case "WARN": return (event) => console.warn(format(event));
|
|
1137
|
+
case "ERROR": return (event) => console.error(format(event));
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
const recordTraceEvent = (logLevel, eventName, attributes) => {
|
|
1141
|
+
if (!shouldLog(LogLevel.LOG)) return;
|
|
1142
|
+
const event = {
|
|
1143
|
+
name: eventName,
|
|
1144
|
+
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
1145
|
+
...attributes
|
|
1146
|
+
};
|
|
1147
|
+
getTraceEventRecorder(logLevel, getEnvVariable("DUMBO_LOG_STYLE") ?? "RAW")(event);
|
|
1148
|
+
};
|
|
1149
|
+
tracer.info = (eventName, attributes) => recordTraceEvent(LogLevel.INFO, eventName, attributes);
|
|
1150
|
+
tracer.warn = (eventName, attributes) => recordTraceEvent(LogLevel.WARN, eventName, attributes);
|
|
1151
|
+
tracer.log = (eventName, attributes) => recordTraceEvent(LogLevel.LOG, eventName, attributes);
|
|
1152
|
+
tracer.error = (eventName, attributes) => recordTraceEvent(LogLevel.ERROR, eventName, attributes);
|
|
1153
|
+
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/eventStore/observability/eventStoreCollector.ts
|
|
1156
|
+
const resolveEventStoreObservability = (options, parent) => ({
|
|
1157
|
+
tracer: options?.observability?.tracer ?? parent?.observability?.tracer ?? noopTracer(),
|
|
1158
|
+
meter: options?.observability?.meter ?? parent?.observability?.meter ?? noopMeter(),
|
|
1159
|
+
attributeTarget: options?.observability?.attributeTarget ?? parent?.observability?.attributeTarget ?? "both"
|
|
1160
|
+
});
|
|
1161
|
+
const eventStoreCollector = (observability) => {
|
|
1162
|
+
const A = EmmettAttributes;
|
|
1163
|
+
const M = MessagingAttributes;
|
|
1164
|
+
const streamReadingDuration = observability.meter.histogram(EmmettMetrics.stream.readingDuration);
|
|
1165
|
+
const streamReadingSize = observability.meter.histogram(EmmettMetrics.stream.readingSize);
|
|
1166
|
+
const eventReadingCount = observability.meter.counter(EmmettMetrics.event.readingCount);
|
|
1167
|
+
const streamAppendingDuration = observability.meter.histogram(EmmettMetrics.stream.appendingDuration);
|
|
1168
|
+
const streamAppendingSize = observability.meter.histogram(EmmettMetrics.stream.appendingSize);
|
|
1169
|
+
const eventAppendingCount = observability.meter.counter(EmmettMetrics.event.appendingCount);
|
|
1170
|
+
return {
|
|
1171
|
+
instrumentRead: (streamName, fn) => {
|
|
1172
|
+
const start = Date.now();
|
|
1173
|
+
return observability.tracer.startSpan("eventStore.readStream", async (span) => {
|
|
1174
|
+
span.setAttributes({
|
|
1175
|
+
[A.eventStore.operation]: "readStream",
|
|
1176
|
+
[A.stream.name]: streamName,
|
|
1177
|
+
[M.operation.type]: "receive",
|
|
1178
|
+
[M.destination.name]: streamName,
|
|
1179
|
+
[M.system]: MessagingSystemName
|
|
1180
|
+
});
|
|
1181
|
+
let status = "success";
|
|
1182
|
+
try {
|
|
1183
|
+
const result = await fn();
|
|
1184
|
+
const events = result.events;
|
|
1185
|
+
span.setAttributes({
|
|
1186
|
+
[A.eventStore.read.status]: status,
|
|
1187
|
+
[A.eventStore.read.eventCount]: events.length,
|
|
1188
|
+
[A.eventStore.read.eventTypes]: [...new Set(events.map((e) => e.type))]
|
|
1189
|
+
});
|
|
1190
|
+
streamReadingSize.record(events.length, { [A.eventStore.read.status]: status });
|
|
1191
|
+
for (const event of events) eventReadingCount.add(1, { [A.event.type]: event.type });
|
|
1192
|
+
return result;
|
|
1193
|
+
} catch (err) {
|
|
1194
|
+
status = "failure";
|
|
1195
|
+
span.setAttributes({ [A.eventStore.read.status]: status });
|
|
1196
|
+
throw err;
|
|
1197
|
+
} finally {
|
|
1198
|
+
streamReadingDuration.record(Date.now() - start, { [A.eventStore.read.status]: status });
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
},
|
|
1202
|
+
instrumentAppend: (streamName, events, fn) => {
|
|
1203
|
+
const start = Date.now();
|
|
1204
|
+
return observability.tracer.startSpan("eventStore.appendToStream", async (span) => {
|
|
1205
|
+
span.setAttributes({
|
|
1206
|
+
[A.eventStore.operation]: "appendToStream",
|
|
1207
|
+
[A.stream.name]: streamName,
|
|
1208
|
+
[A.eventStore.append.batchSize]: events.length,
|
|
1209
|
+
[M.operation.type]: "send",
|
|
1210
|
+
[M.batch.messageCount]: events.length,
|
|
1211
|
+
[M.destination.name]: streamName,
|
|
1212
|
+
[M.system]: MessagingSystemName
|
|
1213
|
+
});
|
|
1214
|
+
let status = "success";
|
|
1215
|
+
try {
|
|
1216
|
+
const result = await fn();
|
|
1217
|
+
span.setAttributes({
|
|
1218
|
+
[A.eventStore.append.status]: status,
|
|
1219
|
+
[A.stream.versionAfter]: Number(result.nextExpectedStreamVersion)
|
|
1220
|
+
});
|
|
1221
|
+
streamAppendingSize.record(events.length, { [A.eventStore.append.status]: status });
|
|
1222
|
+
for (const event of events) eventAppendingCount.add(1, { [A.event.type]: event.type });
|
|
1223
|
+
return result;
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
status = "failure";
|
|
1226
|
+
span.setAttributes({ [A.eventStore.append.status]: status });
|
|
1227
|
+
throw err;
|
|
1228
|
+
} finally {
|
|
1229
|
+
streamAppendingDuration.record(Date.now() - start, { [A.eventStore.append.status]: status });
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/observability/collectors/consumerCollector.ts
|
|
1238
|
+
const consumerCollector = (observability) => {
|
|
1239
|
+
const { startScope } = ObservabilityScope({
|
|
1240
|
+
...observability,
|
|
1241
|
+
attributePrefix: "emmett"
|
|
1242
|
+
});
|
|
1243
|
+
const A = EmmettAttributes;
|
|
1244
|
+
const M = MessagingAttributes;
|
|
1245
|
+
const pollDuration = observability.meter.histogram(EmmettMetrics.consumer.pollDuration);
|
|
1246
|
+
const deliveryDuration = observability.meter.histogram(EmmettMetrics.consumer.deliveryDuration);
|
|
1247
|
+
return {
|
|
1248
|
+
tracePoll: (context, fn) => {
|
|
1249
|
+
if (observability.pollTracing === "off" || observability.pollTracing === "active" && context.batchSize === 0) return fn(noopScope);
|
|
1250
|
+
return startScope("consumer.poll", async (scope) => {
|
|
1251
|
+
scope.setAttributes({
|
|
1252
|
+
[A.scope.type]: ScopeTypes.consumer,
|
|
1253
|
+
[A.consumer.batchSize]: context.batchSize,
|
|
1254
|
+
[A.consumer.processorCount]: context.processorCount,
|
|
1255
|
+
[M.system]: MessagingSystemName,
|
|
1256
|
+
[M.operation.type]: "receive",
|
|
1257
|
+
...context.empty ? { "emmett.consumer.poll.empty": true } : {},
|
|
1258
|
+
...context.waitMs != null ? { "emmett.consumer.poll.wait_ms": context.waitMs } : {}
|
|
1259
|
+
});
|
|
1260
|
+
return fn(scope);
|
|
1261
|
+
});
|
|
1262
|
+
},
|
|
1263
|
+
recordPollMetrics: (durationMs, attrs) => {
|
|
1264
|
+
pollDuration.record(durationMs, attrs);
|
|
1265
|
+
},
|
|
1266
|
+
traceDelivery: (scope, processorId, fn) => {
|
|
1267
|
+
const start = Date.now();
|
|
1268
|
+
return scope.scope(`consumer.deliver.${processorId}`, async (child) => {
|
|
1269
|
+
try {
|
|
1270
|
+
return await fn();
|
|
1271
|
+
} catch (error) {
|
|
1272
|
+
if (error instanceof Error) child.recordException(error);
|
|
1273
|
+
throw error;
|
|
1274
|
+
} finally {
|
|
1275
|
+
deliveryDuration.record(Date.now() - start, { [A.consumer.delivery.processorId]: processorId });
|
|
1276
|
+
}
|
|
1277
|
+
}, { attributes: { [A.consumer.delivery.processorId]: processorId } });
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
//#endregion
|
|
1283
|
+
//#region src/observability/collectors/workflowCollector.ts
|
|
1284
|
+
const workflowCollector = (observability) => {
|
|
1285
|
+
const { startScope } = ObservabilityScope({
|
|
1286
|
+
...observability,
|
|
1287
|
+
attributePrefix: "emmett"
|
|
1288
|
+
});
|
|
1289
|
+
const A = EmmettAttributes;
|
|
1290
|
+
const M = MessagingAttributes;
|
|
1291
|
+
const processingDuration = observability.meter.histogram(EmmettMetrics.workflow.processingDuration);
|
|
1292
|
+
return {
|
|
1293
|
+
startScope: (context, fn) => {
|
|
1294
|
+
const start = Date.now();
|
|
1295
|
+
return startScope("workflow.handle", async (scope) => {
|
|
1296
|
+
scope.setAttributes({
|
|
1297
|
+
[A.scope.type]: ScopeTypes.workflow,
|
|
1298
|
+
[A.workflow.id]: context.workflowId,
|
|
1299
|
+
[A.workflow.type]: context.workflowType,
|
|
1300
|
+
[A.workflow.inputType]: context.inputType,
|
|
1301
|
+
[M.system]: MessagingSystemName
|
|
1302
|
+
});
|
|
1303
|
+
let status = "success";
|
|
1304
|
+
try {
|
|
1305
|
+
return await fn(scope);
|
|
1306
|
+
} catch (err) {
|
|
1307
|
+
status = "failure";
|
|
1308
|
+
throw err;
|
|
1309
|
+
} finally {
|
|
1310
|
+
processingDuration.record(Date.now() - start, {
|
|
1311
|
+
[A.workflow.type]: context.workflowType,
|
|
1312
|
+
status
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
}, { attributes: {
|
|
1316
|
+
[A.scope.type]: ScopeTypes.workflow,
|
|
1317
|
+
[A.workflow.type]: context.workflowType
|
|
1318
|
+
} });
|
|
1319
|
+
},
|
|
1320
|
+
recordOutputs: (scope, outputs) => {
|
|
1321
|
+
scope.setAttributes({
|
|
1322
|
+
[A.workflow.outputs]: outputs.map((o) => o.type),
|
|
1323
|
+
[A.workflow.outputsCount]: outputs.length
|
|
1324
|
+
});
|
|
1325
|
+
},
|
|
1326
|
+
recordStateRebuild: (scope, eventCount) => {
|
|
1327
|
+
scope.setAttributes({ [A.workflow.stateRebuildEventCount]: eventCount });
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
};
|
|
1331
|
+
|
|
979
1332
|
//#endregion
|
|
980
1333
|
//#region src/processors/checkpoints.ts
|
|
981
1334
|
const ProcessorCheckpoint = (checkpoint) => checkpoint;
|
|
@@ -985,6 +1338,88 @@ const getCheckpoint = (message) => {
|
|
|
985
1338
|
return message.metadata.checkpoint;
|
|
986
1339
|
};
|
|
987
1340
|
|
|
1341
|
+
//#endregion
|
|
1342
|
+
//#region src/processors/observability/processorCollector.ts
|
|
1343
|
+
const resolveProcessorObservability = (options, parent) => ({
|
|
1344
|
+
tracer: options?.observability?.tracer ?? parent?.observability?.tracer ?? noopTracer(),
|
|
1345
|
+
meter: options?.observability?.meter ?? parent?.observability?.meter ?? noopMeter(),
|
|
1346
|
+
propagation: options?.observability?.propagation ?? parent?.observability?.propagation ?? "links",
|
|
1347
|
+
attributeTarget: options?.observability?.attributeTarget ?? parent?.observability?.attributeTarget ?? "both",
|
|
1348
|
+
includeMessagePayloads: options?.observability?.includeMessagePayloads ?? parent?.observability?.includeMessagePayloads ?? false
|
|
1349
|
+
});
|
|
1350
|
+
const processorCollector = (observability) => {
|
|
1351
|
+
const { startScope } = ObservabilityScope({
|
|
1352
|
+
...observability,
|
|
1353
|
+
attributePrefix: "emmett"
|
|
1354
|
+
});
|
|
1355
|
+
const A = EmmettAttributes;
|
|
1356
|
+
const M = MessagingAttributes;
|
|
1357
|
+
const processingDuration = observability.meter.histogram(EmmettMetrics.processor.processingDuration);
|
|
1358
|
+
const lagEvents = observability.meter.gauge(EmmettMetrics.processor.lagEvents);
|
|
1359
|
+
return {
|
|
1360
|
+
startScope: (context, messages, fn) => {
|
|
1361
|
+
const sourceLinks = messages.filter((m) => m.metadata?.traceId && m.metadata?.spanId).reduce((acc, m) => {
|
|
1362
|
+
const meta = m.metadata;
|
|
1363
|
+
const link = {
|
|
1364
|
+
traceId: meta.traceId,
|
|
1365
|
+
spanId: meta.spanId
|
|
1366
|
+
};
|
|
1367
|
+
return acc.some((l) => l.traceId === link.traceId && l.spanId === link.spanId) ? acc : [...acc, link];
|
|
1368
|
+
}, []);
|
|
1369
|
+
const start = Date.now();
|
|
1370
|
+
return startScope("processor.handle", async (scope) => {
|
|
1371
|
+
scope.setAttributes({
|
|
1372
|
+
[A.scope.type]: ScopeTypes.processor,
|
|
1373
|
+
[A.processor.id]: context.processorId,
|
|
1374
|
+
[A.processor.type]: context.type,
|
|
1375
|
+
[A.processor.batchSize]: messages.length,
|
|
1376
|
+
[A.processor.eventTypes]: [...new Set(messages.map((m) => m.type))],
|
|
1377
|
+
[M.system]: MessagingSystemName,
|
|
1378
|
+
[M.batch.messageCount]: messages.length,
|
|
1379
|
+
...context.checkpoint ? { [A.processor.checkpointBefore]: context.checkpoint } : {}
|
|
1380
|
+
});
|
|
1381
|
+
let status = "success";
|
|
1382
|
+
try {
|
|
1383
|
+
return await fn(scope);
|
|
1384
|
+
} catch (err) {
|
|
1385
|
+
status = "failure";
|
|
1386
|
+
throw err;
|
|
1387
|
+
} finally {
|
|
1388
|
+
processingDuration.record(Date.now() - start, {
|
|
1389
|
+
[A.processor.id]: context.processorId,
|
|
1390
|
+
[A.processor.type]: context.type,
|
|
1391
|
+
[A.processor.status]: status
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
}, { links: sourceLinks });
|
|
1395
|
+
},
|
|
1396
|
+
startMessageScope: (context, message, batchCtx, fn) => {
|
|
1397
|
+
const meta = message.metadata;
|
|
1398
|
+
const parent = meta?.traceId && meta?.spanId ? {
|
|
1399
|
+
traceId: meta.traceId,
|
|
1400
|
+
spanId: meta.spanId
|
|
1401
|
+
} : void 0;
|
|
1402
|
+
const links = batchCtx.traceId ? [batchCtx] : [];
|
|
1403
|
+
return startScope(`processor.message.${message.type}`, async (scope) => {
|
|
1404
|
+
scope.setAttributes({
|
|
1405
|
+
[A.scope.type]: context.archetypeType,
|
|
1406
|
+
[A.processor.id]: context.processorId,
|
|
1407
|
+
[A.processor.type]: context.type,
|
|
1408
|
+
[M.operation.type]: "process",
|
|
1409
|
+
...meta?.messageId ? { [M.message.id]: meta.messageId } : {}
|
|
1410
|
+
});
|
|
1411
|
+
return fn(scope);
|
|
1412
|
+
}, {
|
|
1413
|
+
parent,
|
|
1414
|
+
links
|
|
1415
|
+
});
|
|
1416
|
+
},
|
|
1417
|
+
recordLag: (processorId, lag) => {
|
|
1418
|
+
lagEvents.record(lag, { [A.processor.id]: processorId });
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
};
|
|
1422
|
+
|
|
988
1423
|
//#endregion
|
|
989
1424
|
//#region src/processors/processors.ts
|
|
990
1425
|
const wasMessageHandled = (message, checkpoint) => {
|
|
@@ -1005,19 +1440,32 @@ const MessageProcessor = { result: {
|
|
|
1005
1440
|
...options ?? {}
|
|
1006
1441
|
})
|
|
1007
1442
|
} };
|
|
1008
|
-
const defaultProcessingMessageProcessingScope = (handler, partialContext) => handler(
|
|
1443
|
+
const defaultProcessingMessageProcessingScope = (handler, partialContext) => handler({
|
|
1444
|
+
...partialContext,
|
|
1445
|
+
observabilityScope: partialContext.observabilityScope ?? noopScope
|
|
1446
|
+
});
|
|
1009
1447
|
const defaultProcessorVersion = 1;
|
|
1010
1448
|
const defaultProcessorPartition = defaultTag;
|
|
1011
1449
|
const getProcessorInstanceId = (processorId) => `${processorId}:${v7()}`;
|
|
1012
1450
|
const getProjectorId = (options) => `emt:processor:projector:${options.projectionName}`;
|
|
1013
1451
|
const reactor = (options) => {
|
|
1014
1452
|
const { checkpoints, processorId, processorInstanceId: instanceId = getProcessorInstanceId(processorId), type = MessageProcessorType.REACTOR, version = 1, partition = defaultProcessorPartition, hooks = {}, processingScope = defaultProcessingMessageProcessingScope, startFrom, canHandle, stopAfter } = options;
|
|
1453
|
+
const collector = processorCollector(resolveProcessorObservability(options));
|
|
1015
1454
|
const isCustomBatch = "eachBatch" in options && !!options.eachBatch;
|
|
1016
1455
|
const eachBatch = isCustomBatch ? options.eachBatch : async (messages, context) => {
|
|
1456
|
+
const batchCtx = context.observabilityScope.spanContext();
|
|
1017
1457
|
let result = void 0;
|
|
1018
1458
|
for (let i = 0; i < messages.length; i++) {
|
|
1019
1459
|
const message = messages[i];
|
|
1020
|
-
const messageProcessingResult = await
|
|
1460
|
+
const messageProcessingResult = await collector.startMessageScope({
|
|
1461
|
+
processorId,
|
|
1462
|
+
type,
|
|
1463
|
+
checkpoint: lastCheckpoint,
|
|
1464
|
+
archetypeType: type
|
|
1465
|
+
}, message, batchCtx, (messageScope) => Promise.resolve(options.eachMessage(message, {
|
|
1466
|
+
...context,
|
|
1467
|
+
observabilityScope: messageScope
|
|
1468
|
+
})));
|
|
1021
1469
|
if (messageProcessingResult && messageProcessingResult.type === "STOP") {
|
|
1022
1470
|
result = {
|
|
1023
1471
|
...messageProcessingResult,
|
|
@@ -1071,8 +1519,19 @@ const reactor = (options) => {
|
|
|
1071
1519
|
instanceId,
|
|
1072
1520
|
type,
|
|
1073
1521
|
canHandle,
|
|
1074
|
-
init
|
|
1075
|
-
|
|
1522
|
+
init: async (partialOptions) => {
|
|
1523
|
+
partialOptions ??= {};
|
|
1524
|
+
await init({
|
|
1525
|
+
...partialOptions,
|
|
1526
|
+
observabilityScope: ("observabilityScope" in partialOptions ? partialOptions.observabilityScope ?? noopScope : noopScope) ?? noopScope
|
|
1527
|
+
});
|
|
1528
|
+
},
|
|
1529
|
+
start: async (partialOptions) => {
|
|
1530
|
+
partialOptions ??= {};
|
|
1531
|
+
const startOptions = {
|
|
1532
|
+
...partialOptions,
|
|
1533
|
+
observabilityScope: ("observabilityScope" in partialOptions ? partialOptions.observabilityScope ?? noopScope : noopScope) ?? noopScope
|
|
1534
|
+
};
|
|
1076
1535
|
if (isActive) {
|
|
1077
1536
|
console.log(`Processor ${processorId} with instance id ${instanceId} is already active. Start request ignored.`);
|
|
1078
1537
|
return;
|
|
@@ -1109,50 +1568,69 @@ const reactor = (options) => {
|
|
|
1109
1568
|
return { lastCheckpoint };
|
|
1110
1569
|
}, startOptions);
|
|
1111
1570
|
},
|
|
1112
|
-
close
|
|
1571
|
+
close: async (partialOptions) => {
|
|
1572
|
+
partialOptions ??= {};
|
|
1573
|
+
await close({
|
|
1574
|
+
...partialOptions,
|
|
1575
|
+
observabilityScope: ("observabilityScope" in partialOptions ? partialOptions.observabilityScope ?? noopScope : noopScope) ?? noopScope
|
|
1576
|
+
});
|
|
1577
|
+
},
|
|
1113
1578
|
get isActive() {
|
|
1114
1579
|
return isActive;
|
|
1115
1580
|
},
|
|
1116
1581
|
handle: async (messages, partialContext) => {
|
|
1117
1582
|
if (!isActive) return Promise.resolve();
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1583
|
+
return collector.startScope({
|
|
1584
|
+
processorId,
|
|
1585
|
+
type,
|
|
1586
|
+
checkpoint: lastCheckpoint
|
|
1587
|
+
}, messages, async (scope) => {
|
|
1588
|
+
try {
|
|
1589
|
+
return await processingScope(async (context) => {
|
|
1590
|
+
const messagesAboveCheckpoint = messages.filter((message) => !wasMessageHandled(message, lastCheckpoint));
|
|
1591
|
+
const upcastedMessages = messagesAboveCheckpoint.map((message) => upcastRecordedMessage(message, options.messageOptions?.schema?.versioning)).filter((upcasted) => !canHandle || canHandle.includes(upcasted.type));
|
|
1592
|
+
const stopMessageIndex = isCustomBatch && stopAfter ? upcastedMessages.findIndex(stopAfter) : -1;
|
|
1593
|
+
const unhandledMessages = stopMessageIndex !== -1 ? upcastedMessages.slice(0, stopMessageIndex + 1) : upcastedMessages;
|
|
1594
|
+
const batchResult = await eachBatch(unhandledMessages, {
|
|
1595
|
+
...context,
|
|
1596
|
+
observabilityScope: scope
|
|
1597
|
+
});
|
|
1598
|
+
const messageProcessingResult = batchResult?.type === "STOP" ? batchResult : stopMessageIndex !== -1 ? {
|
|
1599
|
+
type: "STOP",
|
|
1600
|
+
reason: "Stop condition reached",
|
|
1601
|
+
lastSuccessfulMessage: unhandledMessages[stopMessageIndex]
|
|
1602
|
+
} : batchResult;
|
|
1603
|
+
const isStop = messageProcessingResult && messageProcessingResult.type === "STOP";
|
|
1604
|
+
const checkpointMessage = messageProcessingResult?.type === "STOP" ? messageProcessingResult.lastSuccessfulMessage : messagesAboveCheckpoint[messagesAboveCheckpoint.length - 1];
|
|
1605
|
+
if (checkpointMessage && checkpoints) {
|
|
1606
|
+
const storeCheckpointResult = await checkpoints.store({
|
|
1607
|
+
processorId,
|
|
1608
|
+
version,
|
|
1609
|
+
message: checkpointMessage,
|
|
1610
|
+
lastCheckpoint,
|
|
1611
|
+
partition
|
|
1612
|
+
}, context);
|
|
1613
|
+
if (storeCheckpointResult.success) lastCheckpoint = storeCheckpointResult.newCheckpoint;
|
|
1614
|
+
}
|
|
1615
|
+
scope.setAttributes({ [EmmettAttributes.processor.status]: messageProcessingResult?.type ?? "ack" });
|
|
1616
|
+
if (isStop) {
|
|
1617
|
+
isActive = false;
|
|
1618
|
+
return messageProcessingResult;
|
|
1619
|
+
}
|
|
1620
|
+
}, {
|
|
1621
|
+
...partialContext,
|
|
1622
|
+
observabilityScope: scope
|
|
1623
|
+
});
|
|
1624
|
+
} catch (error) {
|
|
1625
|
+
console.log(`Error during message processing for processor ${processorId} with instance id ${instanceId}. Stopping the processor.`, error);
|
|
1626
|
+
isActive = false;
|
|
1627
|
+
return {
|
|
1126
1628
|
type: "STOP",
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
if (checkpointMessage && checkpoints) {
|
|
1133
|
-
const storeCheckpointResult = await checkpoints.store({
|
|
1134
|
-
processorId,
|
|
1135
|
-
version,
|
|
1136
|
-
message: checkpointMessage,
|
|
1137
|
-
lastCheckpoint,
|
|
1138
|
-
partition
|
|
1139
|
-
}, context);
|
|
1140
|
-
if (storeCheckpointResult.success) lastCheckpoint = storeCheckpointResult.newCheckpoint;
|
|
1141
|
-
}
|
|
1142
|
-
if (isStop) {
|
|
1143
|
-
isActive = false;
|
|
1144
|
-
return messageProcessingResult;
|
|
1145
|
-
}
|
|
1146
|
-
}, partialContext);
|
|
1147
|
-
} catch (error) {
|
|
1148
|
-
console.log(`Error during message processing for processor ${processorId} with instance id ${instanceId}. Stopping the processor.`, error);
|
|
1149
|
-
isActive = false;
|
|
1150
|
-
return {
|
|
1151
|
-
type: "STOP",
|
|
1152
|
-
error,
|
|
1153
|
-
reason: "Error during message processing"
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1629
|
+
error,
|
|
1630
|
+
reason: "Error during message processing"
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1156
1634
|
}
|
|
1157
1635
|
};
|
|
1158
1636
|
};
|
|
@@ -1172,7 +1650,7 @@ const projector = (options) => {
|
|
|
1172
1650
|
} : void 0,
|
|
1173
1651
|
onClose: options.hooks?.onClose
|
|
1174
1652
|
},
|
|
1175
|
-
eachBatch:
|
|
1653
|
+
eachBatch: (events, context) => projection.handle(events, context)
|
|
1176
1654
|
});
|
|
1177
1655
|
};
|
|
1178
1656
|
|
|
@@ -1264,13 +1742,15 @@ const DATABASE_REQUIRED_ERROR_MESSAGE = "Database is required in context for InM
|
|
|
1264
1742
|
* Similar to the PostgreSQL implementation, this processes events through projections
|
|
1265
1743
|
*/
|
|
1266
1744
|
const handleInMemoryProjections = async (options) => {
|
|
1267
|
-
const { projections, events, database, eventStore } = options;
|
|
1745
|
+
const { projections, events, database, eventStore, observability } = options;
|
|
1268
1746
|
const eventTypes = events.map((e) => e.type);
|
|
1269
1747
|
const relevantProjections = projections.filter((p) => p.canHandle.some((type) => eventTypes.includes(type)));
|
|
1270
|
-
|
|
1748
|
+
const { startScope } = ObservabilityScope(observability);
|
|
1749
|
+
for (const projection of relevantProjections) await startScope("eventStore.inlineProjection", async (observabilityScope) => projection.handle(events, {
|
|
1271
1750
|
eventStore,
|
|
1272
|
-
database
|
|
1273
|
-
|
|
1751
|
+
database,
|
|
1752
|
+
observabilityScope
|
|
1753
|
+
}));
|
|
1274
1754
|
};
|
|
1275
1755
|
/**
|
|
1276
1756
|
* Creates an InMemory projection
|
|
@@ -1702,7 +2182,8 @@ const InMemoryProjectionSpec = { for: (options) => {
|
|
|
1702
2182
|
streamExists: async () => {
|
|
1703
2183
|
return Promise.resolve(false);
|
|
1704
2184
|
}
|
|
1705
|
-
}
|
|
2185
|
+
},
|
|
2186
|
+
observability: resolveEventStoreObservability(void 0)
|
|
1706
2187
|
});
|
|
1707
2188
|
};
|
|
1708
2189
|
return {
|
|
@@ -1817,6 +2298,8 @@ const getInMemoryEventStore = (eventStoreOptions) => {
|
|
|
1817
2298
|
};
|
|
1818
2299
|
const database = eventStoreOptions?.database || getInMemoryDatabase();
|
|
1819
2300
|
const inlineProjections = (eventStoreOptions?.projections ?? []).filter(({ type }) => type === "inline").map(({ projection }) => projection);
|
|
2301
|
+
const observability = resolveEventStoreObservability(eventStoreOptions);
|
|
2302
|
+
const collector = eventStoreCollector(observability);
|
|
1820
2303
|
const eventStore = {
|
|
1821
2304
|
database,
|
|
1822
2305
|
async aggregateStream(streamName, options) {
|
|
@@ -1830,55 +2313,62 @@ const getInMemoryEventStore = (eventStoreOptions) => {
|
|
|
1830
2313
|
streamExists: result.streamExists
|
|
1831
2314
|
};
|
|
1832
2315
|
},
|
|
1833
|
-
readStream: (streamName, readOptions) => {
|
|
2316
|
+
readStream: (streamName, readOptions) => collector.instrumentRead(streamName, () => {
|
|
1834
2317
|
const events = streams.get(streamName);
|
|
1835
2318
|
const currentStreamVersion = events ? BigInt(events.length) : InMemoryEventStoreDefaultStreamVersion;
|
|
1836
2319
|
assertExpectedVersionMatchesCurrent(currentStreamVersion, readOptions?.expectedStreamVersion, InMemoryEventStoreDefaultStreamVersion);
|
|
1837
2320
|
const from = Number(readOptions?.from ?? 0);
|
|
1838
2321
|
const to = Number(readOptions?.to ?? (readOptions?.maxCount ? (readOptions.from ?? 0n) + readOptions.maxCount : events?.length ?? 1));
|
|
1839
|
-
const
|
|
2322
|
+
const resultEvents = events !== void 0 && events.length > 0 ? upcastRecordedMessages(events.slice(from, to), readOptions?.schema?.versioning) : [];
|
|
2323
|
+
return Promise.resolve({
|
|
1840
2324
|
currentStreamVersion,
|
|
1841
|
-
events:
|
|
2325
|
+
events: resultEvents,
|
|
1842
2326
|
streamExists: events !== void 0 && events.length > 0
|
|
1843
|
-
};
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
appendToStream: async (streamName, events, options) => {
|
|
2327
|
+
});
|
|
2328
|
+
}),
|
|
2329
|
+
appendToStream: (streamName, events, options) => {
|
|
1847
2330
|
const currentEvents = streams.get(streamName) ?? [];
|
|
1848
2331
|
const currentStreamVersion = currentEvents.length > 0 ? BigInt(currentEvents.length) : InMemoryEventStoreDefaultStreamVersion;
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2332
|
+
return collector.instrumentAppend(streamName, events, async () => {
|
|
2333
|
+
assertExpectedVersionMatchesCurrent(currentStreamVersion, options?.expectedStreamVersion, InMemoryEventStoreDefaultStreamVersion);
|
|
2334
|
+
const newEvents = events.map((event, index) => {
|
|
2335
|
+
const globalPosition = BigInt(getAllEventsCount() + index + 1);
|
|
2336
|
+
const metadata = {
|
|
2337
|
+
streamName,
|
|
2338
|
+
messageId: v4(),
|
|
2339
|
+
streamPosition: BigInt(currentEvents.length + index + 1),
|
|
2340
|
+
globalPosition: bigIntProcessorCheckpoint(globalPosition),
|
|
2341
|
+
checkpoint: bigIntProcessorCheckpoint(globalPosition),
|
|
2342
|
+
...options?.correlationId ? { correlationId: options.correlationId } : {},
|
|
2343
|
+
...options?.causationId ? { causationId: options.causationId } : {},
|
|
2344
|
+
...options?.traceId ? { traceId: options.traceId } : {},
|
|
2345
|
+
...options?.spanId ? { spanId: options.spanId } : {}
|
|
2346
|
+
};
|
|
2347
|
+
return {
|
|
2348
|
+
...event,
|
|
2349
|
+
kind: event.kind ?? "Event",
|
|
2350
|
+
metadata: {
|
|
2351
|
+
..."metadata" in event ? event.metadata ?? {} : {},
|
|
2352
|
+
...metadata
|
|
2353
|
+
}
|
|
2354
|
+
};
|
|
2355
|
+
});
|
|
2356
|
+
const positionOfLastEventInTheStream = BigInt(newEvents.slice(-1)[0].metadata.streamPosition);
|
|
2357
|
+
streams.set(streamName, [...currentEvents, ...downcastRecordedMessages(newEvents, options?.schema?.versioning)]);
|
|
2358
|
+
if (inlineProjections.length > 0) await handleInMemoryProjections({
|
|
2359
|
+
projections: inlineProjections,
|
|
2360
|
+
events: newEvents,
|
|
2361
|
+
database: eventStore.database,
|
|
2362
|
+
eventStore,
|
|
2363
|
+
observability
|
|
2364
|
+
});
|
|
2365
|
+
const result = {
|
|
2366
|
+
nextExpectedStreamVersion: positionOfLastEventInTheStream,
|
|
2367
|
+
createdNewStream: currentStreamVersion === InMemoryEventStoreDefaultStreamVersion
|
|
1866
2368
|
};
|
|
2369
|
+
await tryPublishMessagesAfterCommit(newEvents, eventStoreOptions?.hooks);
|
|
2370
|
+
return result;
|
|
1867
2371
|
});
|
|
1868
|
-
const positionOfLastEventInTheStream = BigInt(newEvents.slice(-1)[0].metadata.streamPosition);
|
|
1869
|
-
streams.set(streamName, [...currentEvents, ...downcastRecordedMessages(newEvents, options?.schema?.versioning)]);
|
|
1870
|
-
if (inlineProjections.length > 0) await handleInMemoryProjections({
|
|
1871
|
-
projections: inlineProjections,
|
|
1872
|
-
events: newEvents,
|
|
1873
|
-
database: eventStore.database,
|
|
1874
|
-
eventStore
|
|
1875
|
-
});
|
|
1876
|
-
const result = {
|
|
1877
|
-
nextExpectedStreamVersion: positionOfLastEventInTheStream,
|
|
1878
|
-
createdNewStream: currentStreamVersion === InMemoryEventStoreDefaultStreamVersion
|
|
1879
|
-
};
|
|
1880
|
-
await tryPublishMessagesAfterCommit(newEvents, eventStoreOptions?.hooks);
|
|
1881
|
-
return result;
|
|
1882
2372
|
},
|
|
1883
2373
|
streamExists: (streamName) => {
|
|
1884
2374
|
const events = streams.get(streamName);
|
|
@@ -1889,168 +2379,13 @@ const getInMemoryEventStore = (eventStoreOptions) => {
|
|
|
1889
2379
|
};
|
|
1890
2380
|
|
|
1891
2381
|
//#endregion
|
|
1892
|
-
//#region src/observability/
|
|
1893
|
-
const EmmettAttributes = {
|
|
1894
|
-
scope: { type: "emmett.scope.type" },
|
|
1895
|
-
command: {
|
|
1896
|
-
type: "emmett.command.type",
|
|
1897
|
-
status: "emmett.command.status",
|
|
1898
|
-
eventCount: "emmett.command.event_count",
|
|
1899
|
-
eventTypes: "emmett.command.event_types"
|
|
1900
|
-
},
|
|
1901
|
-
stream: {
|
|
1902
|
-
name: "emmett.stream.name",
|
|
1903
|
-
versionBefore: "emmett.stream.version.before",
|
|
1904
|
-
versionAfter: "emmett.stream.version.after"
|
|
1905
|
-
},
|
|
1906
|
-
eventStore: {
|
|
1907
|
-
operation: "emmett.eventstore.operation",
|
|
1908
|
-
read: {
|
|
1909
|
-
eventCount: "emmett.eventstore.read.event_count",
|
|
1910
|
-
eventTypes: "emmett.eventstore.read.event_types",
|
|
1911
|
-
status: "emmett.eventstore.read.status"
|
|
1912
|
-
},
|
|
1913
|
-
append: {
|
|
1914
|
-
batchSize: "emmett.eventstore.append.batch_size",
|
|
1915
|
-
status: "emmett.eventstore.append.status"
|
|
1916
|
-
}
|
|
1917
|
-
},
|
|
1918
|
-
event: { type: "emmett.event.type" },
|
|
1919
|
-
processor: {
|
|
1920
|
-
id: "emmett.processor.id",
|
|
1921
|
-
type: "emmett.processor.type",
|
|
1922
|
-
status: "emmett.processor.status",
|
|
1923
|
-
batchSize: "emmett.processor.batch_size",
|
|
1924
|
-
eventTypes: "emmett.processor.event_types",
|
|
1925
|
-
checkpointBefore: "emmett.processor.checkpoint.before",
|
|
1926
|
-
checkpointAfter: "emmett.processor.checkpoint.after",
|
|
1927
|
-
lagEvents: "emmett.processor.lag_events"
|
|
1928
|
-
},
|
|
1929
|
-
workflow: {
|
|
1930
|
-
id: "emmett.workflow.id",
|
|
1931
|
-
type: "emmett.workflow.type",
|
|
1932
|
-
inputType: "emmett.workflow.input.type",
|
|
1933
|
-
outputs: "emmett.workflow.outputs",
|
|
1934
|
-
outputsCount: "emmett.workflow.outputs.count",
|
|
1935
|
-
streamPosition: "emmett.workflow.stream_position",
|
|
1936
|
-
stateRebuildEventCount: "emmett.workflow.state_rebuild.event_count"
|
|
1937
|
-
},
|
|
1938
|
-
consumer: {
|
|
1939
|
-
batchSize: "emmett.consumer.batch_size",
|
|
1940
|
-
processorCount: "emmett.consumer.processor_count",
|
|
1941
|
-
delivery: { processorId: "emmett.consumer.delivery.processor_id" }
|
|
1942
|
-
}
|
|
1943
|
-
};
|
|
1944
|
-
const EmmettMetrics = {
|
|
1945
|
-
command: { handlingDuration: "emmett.command.handling.duration" },
|
|
1946
|
-
event: {
|
|
1947
|
-
appendingCount: "emmett.event.appending.count",
|
|
1948
|
-
readingCount: "emmett.event.reading.count"
|
|
1949
|
-
},
|
|
1950
|
-
stream: {
|
|
1951
|
-
readingDuration: "emmett.stream.reading.duration",
|
|
1952
|
-
readingSize: "emmett.stream.reading.size",
|
|
1953
|
-
appendingDuration: "emmett.stream.appending.duration",
|
|
1954
|
-
appendingSize: "emmett.stream.appending.size"
|
|
1955
|
-
},
|
|
1956
|
-
processor: {
|
|
1957
|
-
processingDuration: "emmett.processor.processing.duration",
|
|
1958
|
-
lagEvents: "emmett.processor.lag_events"
|
|
1959
|
-
},
|
|
1960
|
-
workflow: { processingDuration: "emmett.workflow.processing.duration" },
|
|
1961
|
-
consumer: {
|
|
1962
|
-
pollDuration: "emmett.consumer.poll.duration",
|
|
1963
|
-
deliveryDuration: "emmett.consumer.delivery.duration"
|
|
1964
|
-
}
|
|
1965
|
-
};
|
|
1966
|
-
const ScopeTypes = {
|
|
1967
|
-
command: "command",
|
|
1968
|
-
processor: "processor",
|
|
1969
|
-
reactor: "reactor",
|
|
1970
|
-
projector: "projector",
|
|
1971
|
-
workflow: "workflow",
|
|
1972
|
-
consumer: "consumer"
|
|
1973
|
-
};
|
|
1974
|
-
const MessagingSystemName = "emmett";
|
|
1975
|
-
|
|
1976
|
-
//#endregion
|
|
1977
|
-
//#region src/observability/options.ts
|
|
2382
|
+
//#region src/commandHandling/observability/commandHandlerCollector.ts
|
|
1978
2383
|
const resolveCommandObservability = (options, parent) => ({
|
|
1979
2384
|
tracer: options?.observability?.tracer ?? parent?.observability?.tracer ?? noopTracer(),
|
|
1980
2385
|
meter: options?.observability?.meter ?? parent?.observability?.meter ?? noopMeter(),
|
|
1981
2386
|
attributeTarget: options?.observability?.attributeTarget ?? parent?.observability?.attributeTarget ?? "both",
|
|
1982
2387
|
includeMessagePayloads: options?.observability?.includeMessagePayloads ?? parent?.observability?.includeMessagePayloads ?? false
|
|
1983
2388
|
});
|
|
1984
|
-
|
|
1985
|
-
//#endregion
|
|
1986
|
-
//#region src/observability/tracer.ts
|
|
1987
|
-
const tracer = () => {};
|
|
1988
|
-
const LogLevel = {
|
|
1989
|
-
DISABLED: "DISABLED",
|
|
1990
|
-
INFO: "INFO",
|
|
1991
|
-
LOG: "LOG",
|
|
1992
|
-
WARN: "WARN",
|
|
1993
|
-
ERROR: "ERROR"
|
|
1994
|
-
};
|
|
1995
|
-
const getEnvVariable = (name) => {
|
|
1996
|
-
try {
|
|
1997
|
-
if (typeof process !== "undefined" && process.env) return process.env[name];
|
|
1998
|
-
return;
|
|
1999
|
-
} catch {
|
|
2000
|
-
return;
|
|
2001
|
-
}
|
|
2002
|
-
};
|
|
2003
|
-
const shouldLog = (logLevel) => {
|
|
2004
|
-
const definedLogLevel = getEnvVariable("DUMBO_LOG_LEVEL") ?? LogLevel.ERROR;
|
|
2005
|
-
if (definedLogLevel === LogLevel.ERROR && logLevel === LogLevel.ERROR) return true;
|
|
2006
|
-
if (definedLogLevel === LogLevel.WARN && [LogLevel.ERROR, LogLevel.WARN].includes(logLevel)) return true;
|
|
2007
|
-
if (definedLogLevel === LogLevel.LOG && [
|
|
2008
|
-
LogLevel.ERROR,
|
|
2009
|
-
LogLevel.WARN,
|
|
2010
|
-
LogLevel.LOG
|
|
2011
|
-
].includes(logLevel)) return true;
|
|
2012
|
-
if (definedLogLevel === LogLevel.INFO && [
|
|
2013
|
-
LogLevel.ERROR,
|
|
2014
|
-
LogLevel.WARN,
|
|
2015
|
-
LogLevel.LOG,
|
|
2016
|
-
LogLevel.INFO
|
|
2017
|
-
].includes(logLevel)) return true;
|
|
2018
|
-
return false;
|
|
2019
|
-
};
|
|
2020
|
-
const nulloTraceEventRecorder = () => {};
|
|
2021
|
-
const getTraceEventFormatter = (logStyle, serializer) => (event) => {
|
|
2022
|
-
serializer = serializer ?? JSONSerializer.from();
|
|
2023
|
-
switch (logStyle) {
|
|
2024
|
-
case "RAW": return serializer.serialize(event);
|
|
2025
|
-
case "PRETTY": return serializer.serialize(event);
|
|
2026
|
-
}
|
|
2027
|
-
};
|
|
2028
|
-
const getTraceEventRecorder = (logLevel, logStyle) => {
|
|
2029
|
-
const format = getTraceEventFormatter(logStyle);
|
|
2030
|
-
switch (logLevel) {
|
|
2031
|
-
case "DISABLED": return nulloTraceEventRecorder;
|
|
2032
|
-
case "INFO": return (event) => console.info(format(event));
|
|
2033
|
-
case "LOG": return (event) => console.log(format(event));
|
|
2034
|
-
case "WARN": return (event) => console.warn(format(event));
|
|
2035
|
-
case "ERROR": return (event) => console.error(format(event));
|
|
2036
|
-
}
|
|
2037
|
-
};
|
|
2038
|
-
const recordTraceEvent = (logLevel, eventName, attributes) => {
|
|
2039
|
-
if (!shouldLog(LogLevel.LOG)) return;
|
|
2040
|
-
const event = {
|
|
2041
|
-
name: eventName,
|
|
2042
|
-
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
2043
|
-
...attributes
|
|
2044
|
-
};
|
|
2045
|
-
getTraceEventRecorder(logLevel, getEnvVariable("DUMBO_LOG_STYLE") ?? "RAW")(event);
|
|
2046
|
-
};
|
|
2047
|
-
tracer.info = (eventName, attributes) => recordTraceEvent(LogLevel.INFO, eventName, attributes);
|
|
2048
|
-
tracer.warn = (eventName, attributes) => recordTraceEvent(LogLevel.WARN, eventName, attributes);
|
|
2049
|
-
tracer.log = (eventName, attributes) => recordTraceEvent(LogLevel.LOG, eventName, attributes);
|
|
2050
|
-
tracer.error = (eventName, attributes) => recordTraceEvent(LogLevel.ERROR, eventName, attributes);
|
|
2051
|
-
|
|
2052
|
-
//#endregion
|
|
2053
|
-
//#region src/commandHandling/observability/commandHandlerCollector.ts
|
|
2054
2389
|
const commandHandlerCollector = (observability) => {
|
|
2055
2390
|
const { startScope } = ObservabilityScope({
|
|
2056
2391
|
...observability,
|
|
@@ -2371,82 +2706,95 @@ const createWrappedEvolve = (evolve, workflowName, separateInputInboxFromProcess
|
|
|
2371
2706
|
};
|
|
2372
2707
|
};
|
|
2373
2708
|
const workflowStreamName = ({ workflowName, workflowId }) => `emt:workflow:${workflowName}:${workflowId}`;
|
|
2374
|
-
const WorkflowHandler = (options) => async (store, message, handleOptions) =>
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2709
|
+
const WorkflowHandler = (options) => async (store, message, handleOptions) => {
|
|
2710
|
+
const collector = workflowCollector(resolveWorkflowObservability(options));
|
|
2711
|
+
const workflowType = options.workflow.name;
|
|
2712
|
+
const inputType = message.type;
|
|
2713
|
+
const workflowId = options.getWorkflowId(message) ?? "";
|
|
2714
|
+
return asyncRetry(() => collector.startScope({
|
|
2715
|
+
workflowId,
|
|
2716
|
+
workflowType,
|
|
2717
|
+
inputType
|
|
2718
|
+
}, async (scope) => {
|
|
2719
|
+
return await withSession(store, async ({ eventStore }) => {
|
|
2720
|
+
const { workflow: { evolve, initialState, decide, name: workflowName }, getWorkflowId } = options;
|
|
2721
|
+
const inputMessageId = ("metadata" in message && message.metadata?.messageId ? message.metadata.messageId : void 0) ?? v7();
|
|
2722
|
+
const messageWithMetadata = {
|
|
2723
|
+
...message,
|
|
2724
|
+
metadata: {
|
|
2725
|
+
messageId: inputMessageId,
|
|
2726
|
+
...message.metadata
|
|
2727
|
+
}
|
|
2728
|
+
};
|
|
2729
|
+
const workflowId = getWorkflowId(messageWithMetadata);
|
|
2730
|
+
if (!workflowId) return emptyHandlerResult();
|
|
2731
|
+
const streamName = options.mapWorkflowId ? options.mapWorkflowId(workflowId) : workflowStreamName({
|
|
2732
|
+
workflowName,
|
|
2733
|
+
workflowId
|
|
2734
|
+
});
|
|
2735
|
+
const messageType = messageWithMetadata.type;
|
|
2736
|
+
const hasWorkflowPrefix = messageType.startsWith(`${workflowName}:`);
|
|
2737
|
+
if (options.separateInputInboxFromProcessing && !hasWorkflowPrefix) {
|
|
2738
|
+
const inputMetadata = createInputMetadata(inputMessageId, "InitiatedBy");
|
|
2739
|
+
const inputToStore = {
|
|
2740
|
+
type: `${workflowName}:${messageWithMetadata.type}`,
|
|
2741
|
+
data: messageWithMetadata.data,
|
|
2742
|
+
kind: messageWithMetadata.kind,
|
|
2743
|
+
metadata: inputMetadata
|
|
2744
|
+
};
|
|
2745
|
+
return {
|
|
2746
|
+
...await eventStore.appendToStream(streamName, [inputToStore], {
|
|
2747
|
+
...handleOptions,
|
|
2748
|
+
expectedStreamVersion: handleOptions?.expectedStreamVersion ?? "NO_CONCURRENCY_CHECK"
|
|
2749
|
+
}),
|
|
2750
|
+
newMessages: []
|
|
2751
|
+
};
|
|
2383
2752
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
const
|
|
2753
|
+
const wrappedInitialState = createWrappedInitialState(initialState);
|
|
2754
|
+
const wrappedEvolve = createWrappedEvolve(evolve, workflowName, options.separateInputInboxFromProcessing ?? false);
|
|
2755
|
+
const aggregationResult = await eventStore.aggregateStream(streamName, {
|
|
2756
|
+
evolve: wrappedEvolve,
|
|
2757
|
+
initialState: wrappedInitialState,
|
|
2758
|
+
read: {
|
|
2759
|
+
...handleOptions,
|
|
2760
|
+
expectedStreamVersion: handleOptions?.expectedStreamVersion ?? "NO_CONCURRENCY_CHECK"
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
const { currentStreamVersion } = aggregationResult;
|
|
2764
|
+
collector.recordStateRebuild(scope, Number(currentStreamVersion));
|
|
2765
|
+
const { userState: state, processedInputIds } = aggregationResult.state;
|
|
2766
|
+
if (processedInputIds.has(inputMessageId)) return emptyHandlerResult(currentStreamVersion);
|
|
2767
|
+
const result = decide(hasWorkflowPrefix ? {
|
|
2768
|
+
...messageWithMetadata,
|
|
2769
|
+
type: messageType.replace(`${workflowName}:`, "")
|
|
2770
|
+
} : messageWithMetadata, state);
|
|
2771
|
+
const inputMetadata = createInputMetadata(inputMessageId, aggregationResult.streamExists ? "Received" : "InitiatedBy");
|
|
2395
2772
|
const inputToStore = {
|
|
2396
2773
|
type: `${workflowName}:${messageWithMetadata.type}`,
|
|
2397
2774
|
data: messageWithMetadata.data,
|
|
2398
2775
|
kind: messageWithMetadata.kind,
|
|
2399
2776
|
metadata: inputMetadata
|
|
2400
2777
|
};
|
|
2778
|
+
const outputMessages = (Array.isArray(result) ? result : [result]).filter((msg) => msg !== void 0 && msg !== null);
|
|
2779
|
+
const outputCommandTypes = options.outputs?.commands ?? [];
|
|
2780
|
+
const taggedOutputMessages = outputMessages.map((msg) => {
|
|
2781
|
+
return tagOutputMessage(msg, outputCommandTypes.includes(msg.type) ? "Sent" : "Published");
|
|
2782
|
+
});
|
|
2783
|
+
const messagesToAppend = options.separateInputInboxFromProcessing && hasWorkflowPrefix ? [...taggedOutputMessages] : [inputToStore, ...taggedOutputMessages];
|
|
2784
|
+
if (messagesToAppend.length === 0) return emptyHandlerResult(currentStreamVersion);
|
|
2785
|
+
const expectedStreamVersion = handleOptions?.expectedStreamVersion ?? (aggregationResult.streamExists ? currentStreamVersion : "STREAM_DOES_NOT_EXIST");
|
|
2786
|
+
const appendResult = await eventStore.appendToStream(streamName, messagesToAppend, {
|
|
2787
|
+
...handleOptions,
|
|
2788
|
+
expectedStreamVersion
|
|
2789
|
+
});
|
|
2790
|
+
collector.recordOutputs(scope, outputMessages);
|
|
2401
2791
|
return {
|
|
2402
|
-
...
|
|
2403
|
-
|
|
2404
|
-
expectedStreamVersion: handleOptions?.expectedStreamVersion ?? "NO_CONCURRENCY_CHECK"
|
|
2405
|
-
}),
|
|
2406
|
-
newMessages: []
|
|
2792
|
+
...appendResult,
|
|
2793
|
+
newMessages: outputMessages
|
|
2407
2794
|
};
|
|
2408
|
-
}
|
|
2409
|
-
const wrappedInitialState = createWrappedInitialState(initialState);
|
|
2410
|
-
const wrappedEvolve = createWrappedEvolve(evolve, workflowName, options.separateInputInboxFromProcessing ?? false);
|
|
2411
|
-
const aggregationResult = await eventStore.aggregateStream(streamName, {
|
|
2412
|
-
evolve: wrappedEvolve,
|
|
2413
|
-
initialState: wrappedInitialState,
|
|
2414
|
-
read: {
|
|
2415
|
-
...handleOptions,
|
|
2416
|
-
expectedStreamVersion: handleOptions?.expectedStreamVersion ?? "NO_CONCURRENCY_CHECK"
|
|
2417
|
-
}
|
|
2418
|
-
});
|
|
2419
|
-
const { currentStreamVersion } = aggregationResult;
|
|
2420
|
-
const { userState: state, processedInputIds } = aggregationResult.state;
|
|
2421
|
-
if (processedInputIds.has(inputMessageId)) return emptyHandlerResult(currentStreamVersion);
|
|
2422
|
-
const result = decide(hasWorkflowPrefix ? {
|
|
2423
|
-
...messageWithMetadata,
|
|
2424
|
-
type: messageType.replace(`${workflowName}:`, "")
|
|
2425
|
-
} : messageWithMetadata, state);
|
|
2426
|
-
const inputMetadata = createInputMetadata(inputMessageId, aggregationResult.streamExists ? "Received" : "InitiatedBy");
|
|
2427
|
-
const inputToStore = {
|
|
2428
|
-
type: `${workflowName}:${messageWithMetadata.type}`,
|
|
2429
|
-
data: messageWithMetadata.data,
|
|
2430
|
-
kind: messageWithMetadata.kind,
|
|
2431
|
-
metadata: inputMetadata
|
|
2432
|
-
};
|
|
2433
|
-
const outputMessages = (Array.isArray(result) ? result : [result]).filter((msg) => msg !== void 0 && msg !== null);
|
|
2434
|
-
const outputCommandTypes = options.outputs?.commands ?? [];
|
|
2435
|
-
const taggedOutputMessages = outputMessages.map((msg) => {
|
|
2436
|
-
return tagOutputMessage(msg, outputCommandTypes.includes(msg.type) ? "Sent" : "Published");
|
|
2437
2795
|
});
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
const expectedStreamVersion = handleOptions?.expectedStreamVersion ?? (aggregationResult.streamExists ? currentStreamVersion : "STREAM_DOES_NOT_EXIST");
|
|
2441
|
-
return {
|
|
2442
|
-
...await eventStore.appendToStream(streamName, messagesToAppend, {
|
|
2443
|
-
...handleOptions,
|
|
2444
|
-
expectedStreamVersion
|
|
2445
|
-
}),
|
|
2446
|
-
newMessages: outputMessages
|
|
2447
|
-
};
|
|
2448
|
-
});
|
|
2449
|
-
}, fromWorkflowHandlerRetryOptions(handleOptions && "retry" in handleOptions ? handleOptions.retry : options.retry));
|
|
2796
|
+
}), fromWorkflowHandlerRetryOptions(handleOptions && "retry" in handleOptions ? handleOptions.retry : options.retry));
|
|
2797
|
+
};
|
|
2450
2798
|
const withSession = (eventStore, callback) => {
|
|
2451
2799
|
return (canCreateEventStoreSession(eventStore) ? eventStore : nulloSessionFactory(eventStore)).withSession(callback);
|
|
2452
2800
|
};
|
|
@@ -2520,5 +2868,173 @@ const workflowProcessor = (options) => {
|
|
|
2520
2868
|
};
|
|
2521
2869
|
|
|
2522
2870
|
//#endregion
|
|
2523
|
-
|
|
2871
|
+
//#region src/index.ts
|
|
2872
|
+
var src_exports = /* @__PURE__ */ __exportAll({
|
|
2873
|
+
AssertionError: () => AssertionError,
|
|
2874
|
+
CommandHandler: () => CommandHandler,
|
|
2875
|
+
CommandHandlerStreamVersionConflictRetryOptions: () => CommandHandlerStreamVersionConflictRetryOptions,
|
|
2876
|
+
ConcurrencyError: () => ConcurrencyError,
|
|
2877
|
+
ConcurrencyInMemoryDatabaseError: () => ConcurrencyInMemoryDatabaseError,
|
|
2878
|
+
DATABASE_REQUIRED_ERROR_MESSAGE: () => DATABASE_REQUIRED_ERROR_MESSAGE,
|
|
2879
|
+
DeciderCommandHandler: () => DeciderCommandHandler,
|
|
2880
|
+
DeciderSpecification: () => DeciderSpecification,
|
|
2881
|
+
EmmettAttributes: () => EmmettAttributes,
|
|
2882
|
+
EmmettError: () => EmmettError,
|
|
2883
|
+
EmmettMetrics: () => EmmettMetrics,
|
|
2884
|
+
ExpectedVersionConflictError: () => ExpectedVersionConflictError,
|
|
2885
|
+
GlobalStreamCaughtUpType: () => GlobalStreamCaughtUpType,
|
|
2886
|
+
IllegalStateError: () => IllegalStateError,
|
|
2887
|
+
InMemoryEventStoreDefaultStreamVersion: () => InMemoryEventStoreDefaultStreamVersion,
|
|
2888
|
+
InMemoryProjectionSpec: () => InMemoryProjectionSpec,
|
|
2889
|
+
InProcessLock: () => InProcessLock,
|
|
2890
|
+
JSONCodec: () => JSONCodec,
|
|
2891
|
+
JSONReplacer: () => JSONReplacer,
|
|
2892
|
+
JSONReplacers: () => JSONReplacers,
|
|
2893
|
+
JSONReviver: () => JSONReviver,
|
|
2894
|
+
JSONRevivers: () => JSONRevivers,
|
|
2895
|
+
JSONSerializer: () => JSONSerializer,
|
|
2896
|
+
LogLevel: () => LogLevel,
|
|
2897
|
+
LogStyle: () => LogStyle,
|
|
2898
|
+
MessageProcessor: () => MessageProcessor,
|
|
2899
|
+
MessageProcessorType: () => MessageProcessorType,
|
|
2900
|
+
MessagingSystemName: () => MessagingSystemName,
|
|
2901
|
+
NO_CONCURRENCY_CHECK: () => NO_CONCURRENCY_CHECK,
|
|
2902
|
+
NoRetries: () => NoRetries,
|
|
2903
|
+
NotFoundError: () => NotFoundError,
|
|
2904
|
+
ProcessorCheckpoint: () => ProcessorCheckpoint,
|
|
2905
|
+
STREAM_DOES_NOT_EXIST: () => STREAM_DOES_NOT_EXIST,
|
|
2906
|
+
STREAM_EXISTS: () => STREAM_EXISTS,
|
|
2907
|
+
ScopeTypes: () => ScopeTypes,
|
|
2908
|
+
TaskProcessor: () => TaskProcessor,
|
|
2909
|
+
ValidationError: () => ValidationError,
|
|
2910
|
+
ValidationErrors: () => ValidationErrors,
|
|
2911
|
+
Workflow: () => Workflow,
|
|
2912
|
+
WorkflowHandler: () => WorkflowHandler,
|
|
2913
|
+
WorkflowHandlerStreamVersionConflictRetryOptions: () => WorkflowHandlerStreamVersionConflictRetryOptions,
|
|
2914
|
+
WorkflowSpecification: () => WorkflowSpecification,
|
|
2915
|
+
WrapEventStore: () => WrapEventStore,
|
|
2916
|
+
argMatches: () => argMatches,
|
|
2917
|
+
argValue: () => argValue,
|
|
2918
|
+
arrayUtils: () => arrayUtils,
|
|
2919
|
+
assertDeepEqual: () => assertDeepEqual,
|
|
2920
|
+
assertDefined: () => assertDefined,
|
|
2921
|
+
assertDoesNotThrow: () => assertDoesNotThrow,
|
|
2922
|
+
assertEqual: () => assertEqual,
|
|
2923
|
+
assertExpectedVersionMatchesCurrent: () => assertExpectedVersionMatchesCurrent,
|
|
2924
|
+
assertFails: () => assertFails,
|
|
2925
|
+
assertFalse: () => assertFalse,
|
|
2926
|
+
assertIsNotNull: () => assertIsNotNull,
|
|
2927
|
+
assertIsNull: () => assertIsNull,
|
|
2928
|
+
assertMatches: () => assertMatches,
|
|
2929
|
+
assertNotDeepEqual: () => assertNotDeepEqual,
|
|
2930
|
+
assertNotEmptyString: () => assertNotEmptyString,
|
|
2931
|
+
assertNotEqual: () => assertNotEqual,
|
|
2932
|
+
assertOk: () => assertOk,
|
|
2933
|
+
assertPositiveNumber: () => assertPositiveNumber,
|
|
2934
|
+
assertRejects: () => assertRejects,
|
|
2935
|
+
assertThat: () => assertThat,
|
|
2936
|
+
assertThatArray: () => assertThatArray,
|
|
2937
|
+
assertThrows: () => assertThrows,
|
|
2938
|
+
assertThrowsAsync: () => assertThrowsAsync,
|
|
2939
|
+
assertTrue: () => assertTrue,
|
|
2940
|
+
assertUndefined: () => assertUndefined,
|
|
2941
|
+
assertUnsignedBigInt: () => assertUnsignedBigInt,
|
|
2942
|
+
asyncAwaiter: () => asyncAwaiter,
|
|
2943
|
+
asyncProjections: () => asyncProjections,
|
|
2944
|
+
asyncRetry: () => asyncRetry,
|
|
2945
|
+
bigInt: () => bigInt,
|
|
2946
|
+
bigIntProcessorCheckpoint: () => bigIntProcessorCheckpoint,
|
|
2947
|
+
canCreateEventStoreSession: () => canCreateEventStoreSession,
|
|
2948
|
+
caughtUpEventFrom: () => caughtUpEventFrom,
|
|
2949
|
+
command: () => command,
|
|
2950
|
+
composeJSONReplacers: () => composeJSONReplacers,
|
|
2951
|
+
composeJSONRevivers: () => composeJSONRevivers,
|
|
2952
|
+
consumerCollector: () => consumerCollector,
|
|
2953
|
+
deepEquals: () => deepEquals,
|
|
2954
|
+
defaultProcessingMessageProcessingScope: () => defaultProcessingMessageProcessingScope,
|
|
2955
|
+
defaultProcessorPartition: () => defaultProcessorPartition,
|
|
2956
|
+
defaultProcessorVersion: () => 1,
|
|
2957
|
+
defaultTag: () => defaultTag,
|
|
2958
|
+
delay: () => delay,
|
|
2959
|
+
documentExists: () => documentExists,
|
|
2960
|
+
downcastRecordedMessage: () => downcastRecordedMessage,
|
|
2961
|
+
downcastRecordedMessages: () => downcastRecordedMessages,
|
|
2962
|
+
emmettPrefix: () => "emt",
|
|
2963
|
+
event: () => event,
|
|
2964
|
+
eventInStream: () => eventInStream,
|
|
2965
|
+
eventStoreCollector: () => eventStoreCollector,
|
|
2966
|
+
eventsInStream: () => eventsInStream,
|
|
2967
|
+
expectInMemoryDocuments: () => expectInMemoryDocuments,
|
|
2968
|
+
filterProjections: () => filterProjections,
|
|
2969
|
+
formatDateToUtcYYYYMMDD: () => formatDateToUtcYYYYMMDD,
|
|
2970
|
+
forwardToMessageBus: () => forwardToMessageBus,
|
|
2971
|
+
getCheckpoint: () => getCheckpoint,
|
|
2972
|
+
getInMemoryDatabase: () => getInMemoryDatabase,
|
|
2973
|
+
getInMemoryEventStore: () => getInMemoryEventStore,
|
|
2974
|
+
getInMemoryMessageBus: () => getInMemoryMessageBus,
|
|
2975
|
+
getProcessorInstanceId: () => getProcessorInstanceId,
|
|
2976
|
+
getProjectorId: () => getProjectorId,
|
|
2977
|
+
getWorkflowId: () => getWorkflowId,
|
|
2978
|
+
globalStreamCaughtUp: () => globalStreamCaughtUp,
|
|
2979
|
+
globalTag: () => globalTag,
|
|
2980
|
+
guardBoundedAccess: () => guardBoundedAccess,
|
|
2981
|
+
guardExclusiveAccess: () => guardExclusiveAccess,
|
|
2982
|
+
guardInitializedOnce: () => guardInitializedOnce,
|
|
2983
|
+
handleInMemoryProjections: () => handleInMemoryProjections,
|
|
2984
|
+
hashText: () => hashText,
|
|
2985
|
+
inMemoryCheckpointer: () => inMemoryCheckpointer,
|
|
2986
|
+
inMemoryMultiStreamProjection: () => inMemoryMultiStreamProjection,
|
|
2987
|
+
inMemoryProjection: () => inMemoryProjection,
|
|
2988
|
+
inMemoryProjector: () => inMemoryProjector,
|
|
2989
|
+
inMemoryReactor: () => inMemoryReactor,
|
|
2990
|
+
inMemorySingleStreamProjection: () => inMemorySingleStreamProjection,
|
|
2991
|
+
inlineProjections: () => inlineProjections,
|
|
2992
|
+
isBigint: () => isBigint,
|
|
2993
|
+
isEquatable: () => isEquatable,
|
|
2994
|
+
isErrorConstructor: () => isErrorConstructor,
|
|
2995
|
+
isExpectedVersionConflictError: () => isExpectedVersionConflictError,
|
|
2996
|
+
isGlobalStreamCaughtUp: () => isGlobalStreamCaughtUp,
|
|
2997
|
+
isNotInternalEvent: () => isNotInternalEvent,
|
|
2998
|
+
isNumber: () => isNumber,
|
|
2999
|
+
isPluginConfig: () => isPluginConfig,
|
|
3000
|
+
isString: () => isString,
|
|
3001
|
+
isSubscriptionEvent: () => isSubscriptionEvent,
|
|
3002
|
+
isSubset: () => isSubset,
|
|
3003
|
+
isValidYYYYMMDD: () => isValidYYYYMMDD,
|
|
3004
|
+
jsonSerializer: () => jsonSerializer,
|
|
3005
|
+
matchesExpectedVersion: () => matchesExpectedVersion,
|
|
3006
|
+
merge: () => merge,
|
|
3007
|
+
message: () => message,
|
|
3008
|
+
newEventsInStream: () => newEventsInStream,
|
|
3009
|
+
nulloSessionFactory: () => nulloSessionFactory,
|
|
3010
|
+
onShutdown: () => onShutdown,
|
|
3011
|
+
parseBigIntProcessorCheckpoint: () => parseBigIntProcessorCheckpoint,
|
|
3012
|
+
parseDateFromUtcYYYYMMDD: () => parseDateFromUtcYYYYMMDD,
|
|
3013
|
+
processorCollector: () => processorCollector,
|
|
3014
|
+
projection: () => projection,
|
|
3015
|
+
projections: () => projections,
|
|
3016
|
+
projector: () => projector,
|
|
3017
|
+
reactor: () => reactor,
|
|
3018
|
+
reduceAsync: () => reduceAsync,
|
|
3019
|
+
resolveConsumerObservability: () => resolveConsumerObservability,
|
|
3020
|
+
resolveEventStoreObservability: () => resolveEventStoreObservability,
|
|
3021
|
+
resolveProcessorObservability: () => resolveProcessorObservability,
|
|
3022
|
+
resolveWorkflowObservability: () => resolveWorkflowObservability,
|
|
3023
|
+
sum: () => sum,
|
|
3024
|
+
toNormalizedString: () => toNormalizedString,
|
|
3025
|
+
tracer: () => tracer,
|
|
3026
|
+
tryPublishMessagesAfterCommit: () => tryPublishMessagesAfterCommit,
|
|
3027
|
+
unknownTag: () => unknownTag,
|
|
3028
|
+
upcastRecordedMessage: () => upcastRecordedMessage,
|
|
3029
|
+
upcastRecordedMessages: () => upcastRecordedMessages,
|
|
3030
|
+
verifyThat: () => verifyThat,
|
|
3031
|
+
wasMessageHandled: () => wasMessageHandled,
|
|
3032
|
+
workflowCollector: () => workflowCollector,
|
|
3033
|
+
workflowOutputHandler: () => workflowOutputHandler,
|
|
3034
|
+
workflowProcessor: () => workflowProcessor,
|
|
3035
|
+
workflowStreamName: () => workflowStreamName
|
|
3036
|
+
});
|
|
3037
|
+
|
|
3038
|
+
//#endregion
|
|
3039
|
+
export { AssertionError, CommandHandler, CommandHandlerStreamVersionConflictRetryOptions, ConcurrencyError, ConcurrencyInMemoryDatabaseError, DATABASE_REQUIRED_ERROR_MESSAGE, DeciderCommandHandler, DeciderSpecification, EmmettAttributes, EmmettError, EmmettMetrics, ExpectedVersionConflictError, GlobalStreamCaughtUpType, IllegalStateError, InMemoryEventStoreDefaultStreamVersion, InMemoryProjectionSpec, InProcessLock, JSONCodec, JSONReplacer, JSONReplacers, JSONReviver, JSONRevivers, JSONSerializer, LogLevel, LogStyle, MessageProcessor, MessageProcessorType, MessagingSystemName, NO_CONCURRENCY_CHECK, NoRetries, NotFoundError, ProcessorCheckpoint, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, ScopeTypes, TaskProcessor, ValidationError, ValidationErrors, Workflow, WorkflowHandler, WorkflowHandlerStreamVersionConflictRetryOptions, WorkflowSpecification, WrapEventStore, argMatches, argValue, arrayUtils, assertDeepEqual, assertDefined, assertDoesNotThrow, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUndefined, assertUnsignedBigInt, asyncAwaiter, asyncProjections, asyncRetry, bigInt, bigIntProcessorCheckpoint, canCreateEventStoreSession, caughtUpEventFrom, command, composeJSONReplacers, composeJSONRevivers, consumerCollector, deepEquals, defaultProcessingMessageProcessingScope, defaultProcessorPartition, defaultProcessorVersion, defaultTag, delay, documentExists, downcastRecordedMessage, downcastRecordedMessages, emmettPrefix, event, eventInStream, eventStoreCollector, eventsInStream, expectInMemoryDocuments, filterProjections, formatDateToUtcYYYYMMDD, forwardToMessageBus, getCheckpoint, getInMemoryDatabase, getInMemoryEventStore, getInMemoryMessageBus, getProcessorInstanceId, getProjectorId, getWorkflowId, globalStreamCaughtUp, globalTag, guardBoundedAccess, guardExclusiveAccess, guardInitializedOnce, handleInMemoryProjections, hashText, inMemoryCheckpointer, inMemoryMultiStreamProjection, inMemoryProjection, inMemoryProjector, inMemoryReactor, inMemorySingleStreamProjection, inlineProjections, isBigint, isEquatable, isErrorConstructor, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isPluginConfig, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, jsonSerializer, matchesExpectedVersion, merge, message, newEventsInStream, nulloSessionFactory, onShutdown, parseBigIntProcessorCheckpoint, parseDateFromUtcYYYYMMDD, processorCollector, projection, projections, projector, reactor, reduceAsync, resolveConsumerObservability, resolveEventStoreObservability, resolveProcessorObservability, resolveWorkflowObservability, sum, toNormalizedString, tracer, tryPublishMessagesAfterCommit, unknownTag, upcastRecordedMessage, upcastRecordedMessages, verifyThat, wasMessageHandled, workflowCollector, workflowOutputHandler, workflowProcessor, workflowStreamName };
|
|
2524
3040
|
//# sourceMappingURL=index.js.map
|