UNPKG

pg-transactional-outbox

Version:

A PostgreSQL based transactional outbox and inbox pattern implementation to support exactly once message processing (with at least once message delivery).

23 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultPollingListenerBatchSizeStrategy = void 0; /** * The default batch size strategy returns the configured value from the * `nextMessagesBatchSize`. But the first few times until the batch size is * reached it will tell to return only one message. This protects against * poisonous messages: if the full batch size would be taken during startup all * those messages would be marked as poisonous if one of them fails. */ const defaultPollingListenerBatchSizeStrategy = (config) => { let callsSinceStart = 1; return () => { let batchSize = config.settings.nextMessagesBatchSize; if (callsSinceStart <= config.settings.nextMessagesBatchSize) { batchSize = 1; callsSinceStart++; } return Promise.resolve(batchSize); }; }; exports.defaultPollingListenerBatchSizeStrategy = defaultPollingListenerBatchSizeStrategy; //# sourceMappingURL=batch-size-strategy.js.map