UNPKG

@arturwojnar/hermes-postgresql

Version:

Production-Ready TypeScript Outbox Pattern for PostgreSQL

21 lines (20 loc) 983 B
import { Duration } from '@arturwojnar/hermes'; import { EventEmitter } from 'events'; import { AsyncOrSync } from 'ts-essentials'; import { type Lsn } from './common/lsn'; import { type EventEnvelope } from './common/types'; import { type InsertResult, type MessageType, type Transaction } from './subscribeToReplicationSlot/types'; declare class TransactionManager<Event> extends EventEmitter { private readonly publish; private currentTransaction?; private lastAcknowledgedLsn; private isProcessing; private processingTimeout; constructor(publish: (event: EventEnvelope<Event> | EventEnvelope<Event>[]) => AsyncOrSync<void>, initialLsn: Lsn, processingTimeout?: Duration); beginTransaction(transaction: Transaction): void; addInsert(result: InsertResult): void; commitTransaction(): Promise<void>; getLastAcknowledgedLsn(): Lsn; retry(): Promise<void>; } export { MessageType, TransactionManager, type InsertResult, type Transaction };