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).
18 lines • 1.13 kB
TypeScript
import { TransactionalLogger } from '../common/logger';
export interface AcknowledgeManager {
startProcessingLSN: (lsn: string) => void;
finishProcessingLSN: (lsn: string) => void;
}
/**
* This LSN acknowledge manager cares about remembering the LSN numbers that
* were sent from PostgreSQL and acknowledge the LSN only after all the LSNs
* before were acknowledged as well. With the `startProcessingLSN` it tracks
* the LSN and with `finishProcessingLSN` it marks this LSN as finished. It
* checks then which (if any) LSN can be acknowledged (no older LSNs are in
* pending state) and executed the `acknowledgeLsn` callback.
* @param acknowledgeLsn Callback to actually acknowledge the WAL message
* @param logger A logger instance for logging trace up to error logs
* @returns two functions - one to be called when starting the WAL processing and one when the processing is done and the acknowledgement can be done.
*/
export declare const createAcknowledgeManager: (acknowledgeLsn: (lsn: string) => void, logger: TransactionalLogger) => AcknowledgeManager;
//# sourceMappingURL=acknowledge-manager.d.ts.map