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

74 lines 3.92 kB
import { Env } from '../common/env-settings'; import { ListenerConfig, ListenerSettings } from '../common/listener-config'; export type FullPollingListenerConfig = Required<PollingListenerConfig> & { settings: FullPollingListenerSettings; }; export type FullPollingListenerSettings = Required<PollingListenerSettings>; export interface PollingListenerConfig extends ListenerConfig { /** Polling listener specific settings */ settings: PollingListenerSettings; } export interface PollingListenerSettings extends ListenerSettings { /** * The name of the schema of the Postgres function to get the next batch of * messages. It defaults to the `dbSchema` if it is not provided. */ nextMessagesFunctionSchema?: string; /** * The name of the Postgres function to get the next batch of outbox or inbox * messages. */ nextMessagesFunctionName: string; /** The batch size for messages to load simultaneously. Default is 5. */ nextMessagesBatchSize?: number; /** How long should a message be locked for exclusive processing and error handling (in milliseconds). Default is 5 seconds. */ nextMessagesLockInMs?: number; /** Next polling interval. Default is 500ms. */ nextMessagesPollingIntervalInMs?: number; } export declare const applyDefaultPollingListenerConfigValues: (config: PollingListenerConfig) => FullPollingListenerConfig; /** * Loads the environment variables into the polling listener settings object. It * supports reading an inbox specific setting or a general one. * Please use the `getInboxPollingListenerEnvTemplate` functions to get a * list of all the inbox relevant settings for the polling listener. * @example * TRX_DB_SCHEMA=trx_schema * TRX_INBOX_DB_TABLE=inbox_table * TRX_INBOX_NEXT_MESSAGES_FUNCTION_SCHEMA=next_inbox_messages * @param env The process.env variable or a custom object. * @returns The polling listener settings object with filled with the ENV variables */ export declare const getInboxPollingListenerSettings: (env?: Env) => PollingListenerSettings; /** * Loads the environment variables into the polling listener settings object. It * supports reading an outbox specific setting or a general one. * Please use the `getOutboxPollingListenerEnvTemplate` functions to get a * list of all the outbox relevant settings for the polling listener. * @example * TRX_DB_SCHEMA=trx_schema * TRX_OUTBOX_DB_TABLE=outbox_table * TRX_OUTBOX_NEXT_MESSAGES_FUNCTION_SCHEMA=next_outbox_messages * @param env The process.env variable or a custom object. * @returns The polling listener settings object with filled with the ENV variables */ export declare const getOutboxPollingListenerSettings: (env?: Env) => PollingListenerSettings; /** * Shows the available env variables and their default values for the inbox * listener with the polling approach. * @param map A mapping of all the env variables to config settings. * @param envPrefix The prefix for the env variables to check first (e.g. "TRX_INBOX_" or "TRX_"). * @param envPrefixFallback The fallback prefix if the other is not found. Useful for defining settings that should be used for both outbox and inbox. * @returns */ export declare const getInboxPollingListenerEnvTemplate: (defaultOverrides?: Record<string, string>) => string; /** * Shows the available env variables and their default values for the outbox * listener with the polling approach. * @param map A mapping of all the env variables to config settings. * @param envPrefix The prefix for the env variables to check first (e.g. "TRX_OUTBOX_" or "TRX_"). * @param envPrefixFallback The fallback prefix if the other is not found. Useful for defining settings that should be used for both outbox and inbox. * @returns */ export declare const getOutboxPollingListenerEnvTemplate: (defaultOverrides?: Record<string, string>) => string; //# sourceMappingURL=config.d.ts.map