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).

30 lines 1.97 kB
import { Pool } from 'pg'; import { DatabaseClient } from '../common/database'; import { ListenerConfig } from '../common/listener-config'; import { TransactionalLogger } from '../common/logger'; export interface DeleteOld { /** Delete messages where the processed field is older than the configured seconds */ deleteProcessedInSec?: number; /** Delete messages where the abandoned field is older than the configured seconds */ deleteAbandonedInSec?: number; /** Delete messages where the created field is older than the configured seconds */ deleteAllInSec?: number; } /** * Deletes messages from the inbox. Please keep in mind that messages should * stay for some time especially in the inbox to handle message deduplication. * @param timesInSeconds Delete messages that * @param client A database client or directly the database pool. The used DB role must have permissions to delete messages. This is by default the case for the listener role. * @param config The configuration settings that defines the database schema. * @returns The number of deleted rows */ export declare const runMessageCleanupOnce: (client: DatabaseClient, { settings: { dbSchema, dbTable, messageCleanupProcessedInSec, messageCleanupAbandonedInSec, messageCleanupAllInSec, }, }: Pick<ListenerConfig, "settings">) => Promise<number>; /** * * @param pool The database pool that should be used to run the cleanup queries. The used DB role must have permissions to delete messages. This is by default the case for the listener role. * @param config The configuration settings that defines the database schema. * @param logger A logger object used to log processing issues. * @returns A timeout from setInterval that you must call once the cleanup should be stopped. */ export declare const runScheduledMessageCleanup: (pool: Pool, config: ListenerConfig, logger: TransactionalLogger) => NodeJS.Timeout | undefined; //# sourceMappingURL=message-cleanup.d.ts.map