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