@arturwojnar/hermes-postgresql
Version:
Production-Ready TypeScript Outbox Pattern for PostgreSQL
19 lines (18 loc) • 849 B
TypeScript
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 './types';
declare class TransactionManager<Event> extends EventEmitter {
private readonly publish;
private currentTransaction?;
private lastAcknowledgedLsn;
private isProcessing;
constructor(publish: (event: EventEnvelope<Event> | EventEnvelope<Event>[]) => AsyncOrSync<void>, initialLsn: Lsn);
beginTransaction(transaction: Transaction): void;
addInsert(result: InsertResult): void;
commitTransaction(): Promise<void>;
getLastAcknowledgedLsn(): Lsn;
retry(): Promise<void>;
}
export { MessageType, TransactionManager, type InsertResult, type Transaction };