@event-driven-io/emmett-postgresql 0.43.0-beta.24 → 0.43.0-beta.26
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/index.cjs +38 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +40 -43
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3037,11 +3037,6 @@ const postgreSQLEventStoreMessageBatchPuller = ({ executor, batchSize, eachBatch
|
|
|
3037
3037
|
}
|
|
3038
3038
|
};
|
|
3039
3039
|
};
|
|
3040
|
-
const zipPostgreSQLEventStoreMessageBatchPullerStartFrom = (options) => {
|
|
3041
|
-
if (options.length === 0 || options.some((o) => o === void 0 || o === "BEGINNING")) return "BEGINNING";
|
|
3042
|
-
if (options.every((o) => o === "END")) return "END";
|
|
3043
|
-
return options.filter((o) => o !== void 0 && o !== "BEGINNING" && o !== "END").sort((a, b) => a > b ? 1 : -1)[0];
|
|
3044
|
-
};
|
|
3045
3040
|
|
|
3046
3041
|
//#endregion
|
|
3047
3042
|
//#region src/eventStore/consumers/postgreSQLProcessor.ts
|
|
@@ -3169,7 +3164,7 @@ const postgreSQLProjector = (options) => {
|
|
|
3169
3164
|
processorId,
|
|
3170
3165
|
partition
|
|
3171
3166
|
}),
|
|
3172
|
-
checkpoints: postgreSQLCheckpointer()
|
|
3167
|
+
checkpoints: options.checkpoints === "DISABLED" ? (0, _event_driven_io_emmett.inMemoryCheckpointer)() : postgreSQLCheckpointer()
|
|
3173
3168
|
});
|
|
3174
3169
|
};
|
|
3175
3170
|
const postgreSQLWorkflowProcessor = (options) => {
|
|
@@ -3204,7 +3199,7 @@ const postgreSQLWorkflowProcessor = (options) => {
|
|
|
3204
3199
|
processorId,
|
|
3205
3200
|
partition
|
|
3206
3201
|
}),
|
|
3207
|
-
checkpoints: postgreSQLCheckpointer()
|
|
3202
|
+
checkpoints: options.checkpoints === "DISABLED" ? (0, _event_driven_io_emmett.inMemoryCheckpointer)() : postgreSQLCheckpointer()
|
|
3208
3203
|
});
|
|
3209
3204
|
};
|
|
3210
3205
|
const postgreSQLReactor = (options) => {
|
|
@@ -3239,7 +3234,7 @@ const postgreSQLReactor = (options) => {
|
|
|
3239
3234
|
processorId,
|
|
3240
3235
|
partition
|
|
3241
3236
|
}),
|
|
3242
|
-
checkpoints: postgreSQLCheckpointer()
|
|
3237
|
+
checkpoints: options.checkpoints === "DISABLED" ? (0, _event_driven_io_emmett.inMemoryCheckpointer)() : postgreSQLCheckpointer()
|
|
3243
3238
|
});
|
|
3244
3239
|
};
|
|
3245
3240
|
|
|
@@ -3259,24 +3254,6 @@ const postgreSQLEventStoreConsumer = (options) => {
|
|
|
3259
3254
|
connectionString: options.connectionString,
|
|
3260
3255
|
serialization: options.serialization
|
|
3261
3256
|
});
|
|
3262
|
-
const eachBatch = async (messagesBatch) => {
|
|
3263
|
-
const activeProcessors = processors.filter((s) => s.isActive);
|
|
3264
|
-
if (activeProcessors.length === 0) return {
|
|
3265
|
-
type: "STOP",
|
|
3266
|
-
reason: "No active processors"
|
|
3267
|
-
};
|
|
3268
|
-
return (await Promise.allSettled(activeProcessors.map(async (s) => {
|
|
3269
|
-
try {
|
|
3270
|
-
return await s.handle(messagesBatch, { connection: {
|
|
3271
|
-
connectionString: options.connectionString,
|
|
3272
|
-
pool
|
|
3273
|
-
} });
|
|
3274
|
-
} catch (error) {
|
|
3275
|
-
console.log(`Error during message batch processing for processor: ${s.id}`, error);
|
|
3276
|
-
throw error;
|
|
3277
|
-
}
|
|
3278
|
-
}))).some((r) => r.status === "fulfilled" && r.value?.type !== "STOP") ? void 0 : { type: "STOP" };
|
|
3279
|
-
};
|
|
3280
3257
|
const processorContext = {
|
|
3281
3258
|
execute: pool.execute,
|
|
3282
3259
|
connection: {
|
|
@@ -3358,6 +3335,26 @@ const postgreSQLEventStoreConsumer = (options) => {
|
|
|
3358
3335
|
abortController = new AbortController();
|
|
3359
3336
|
start = (async () => {
|
|
3360
3337
|
if (!isRunning) return;
|
|
3338
|
+
let startPositions = void 0;
|
|
3339
|
+
const eachBatch = async (messagesBatch) => {
|
|
3340
|
+
const activeProcessors = processors.filter((s) => s.isActive);
|
|
3341
|
+
if (activeProcessors.length === 0) return {
|
|
3342
|
+
type: "STOP",
|
|
3343
|
+
reason: "No active processors"
|
|
3344
|
+
};
|
|
3345
|
+
return (await Promise.allSettled(activeProcessors.map(async (s) => {
|
|
3346
|
+
const batch = startPositions.afterStartPosition(s.id, messagesBatch);
|
|
3347
|
+
try {
|
|
3348
|
+
return await s.handle(batch, { connection: {
|
|
3349
|
+
connectionString: options.connectionString,
|
|
3350
|
+
pool
|
|
3351
|
+
} });
|
|
3352
|
+
} catch (error) {
|
|
3353
|
+
console.log(`Error during message batch processing for processor: ${s.id}`, error);
|
|
3354
|
+
throw error;
|
|
3355
|
+
}
|
|
3356
|
+
}))).some((r) => r.status === "fulfilled" && r.value?.type !== "STOP") ? void 0 : { type: "STOP" };
|
|
3357
|
+
};
|
|
3361
3358
|
try {
|
|
3362
3359
|
messagePuller = postgreSQLEventStoreMessageBatchPuller({
|
|
3363
3360
|
stopWhen: options.stopWhen,
|
|
@@ -3371,23 +3368,23 @@ const postgreSQLEventStoreConsumer = (options) => {
|
|
|
3371
3368
|
console.log("Initializing consumer before starting message pulling.");
|
|
3372
3369
|
await init();
|
|
3373
3370
|
}
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3371
|
+
startPositions = await pool.withConnection((connection) => _event_driven_io_emmett.ConsumerStartPositions.resolve({
|
|
3372
|
+
processors,
|
|
3373
|
+
handlerContext: {
|
|
3374
|
+
execute: pool.execute,
|
|
3375
|
+
connection: {
|
|
3376
|
+
connectionString: options.connectionString,
|
|
3377
|
+
pool
|
|
3378
|
+
}
|
|
3379
|
+
},
|
|
3380
|
+
readLastMessageCheckpoint: async () => {
|
|
3381
|
+
const { currentCheckpoint } = await readLastMessageCheckpoint(connection.execute);
|
|
3382
|
+
return currentCheckpoint !== null ? PostgreSQLEventStoreCheckpoint.toProcessorCheckpoint(currentCheckpoint) : null;
|
|
3386
3383
|
}
|
|
3387
|
-
}))
|
|
3388
|
-
console.log(`Starting message pulling with start position: ${_event_driven_io_dumbo.JSONSerializer.serialize(
|
|
3384
|
+
}));
|
|
3385
|
+
console.log(`Starting message pulling with start position: ${_event_driven_io_dumbo.JSONSerializer.serialize(startPositions.earliestPosition)}. Waiting for messages...`);
|
|
3389
3386
|
await messagePuller.start({
|
|
3390
|
-
startFrom,
|
|
3387
|
+
startFrom: startPositions.earliestPosition,
|
|
3391
3388
|
started: startedAwaiter
|
|
3392
3389
|
});
|
|
3393
3390
|
} catch (error) {
|
|
@@ -3527,5 +3524,4 @@ exports.toProjectionLockKey = toProjectionLockKey;
|
|
|
3527
3524
|
exports.transactionToPostgreSQLProjectionHandlerContext = transactionToPostgreSQLProjectionHandlerContext;
|
|
3528
3525
|
exports.tryAcquireProcessorLockSQL = tryAcquireProcessorLockSQL;
|
|
3529
3526
|
exports.tryAcquireProjectionLockSQL = tryAcquireProjectionLockSQL;
|
|
3530
|
-
exports.zipPostgreSQLEventStoreMessageBatchPullerStartFrom = zipPostgreSQLEventStoreMessageBatchPullerStartFrom;
|
|
3531
3527
|
//# sourceMappingURL=index.cjs.map
|