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).
66 lines • 3.94 kB
TypeScript
import { Env } from '../common/env-settings';
import { ListenerConfig, ListenerSettings } from '../common/listener-config';
export type FullReplicationListenerConfig = Required<ReplicationListenerConfig> & {
settings: FullReplicationListenerSettings;
};
export type FullReplicationListenerSettings = Required<ReplicationListenerSettings>;
export interface ReplicationListenerConfig extends ListenerConfig {
/** Replication listener specific configurations */
settings: ReplicationListenerSettings;
}
export interface ReplicationListenerSettings extends ListenerSettings {
/** The name of the used PostgreSQL publication */
dbPublication: string;
/** The name of the used PostgreSQL logical replication slot */
dbReplicationSlot: string;
/** When there is a message processing error it restarts the logical replication subscription with a delay. This setting defines this delay in milliseconds. Default is 250ms. */
restartDelayInMs?: number;
/** When the replication slot is in use e.g. by another service, this service will still continue to try to connect in case the other service stops. Delay is given in milliseconds, the default is 10s. */
restartDelaySlotInUseInMs?: number;
}
export declare const applyDefaultReplicationListenerConfigValues: (config: ReplicationListenerConfig) => FullReplicationListenerConfig;
/**
* Loads the environment variables into the replication listener settings
* object. It supports reading an inbox specific setting or a general one.
* Please use the `getInboxReplicationListenerEnvTemplate` functions to get a
* list of all the inbox relevant settings for the replication listener.
* @example
* TRX_DB_SCHEMA=trx_schema
* TRX_INBOX_DB_TABLE=inbox_table
* TRX_INBOX_DB_REPLICATION_SLOT=pg_transactional_inbox_slot
* @param env The process.env variable or a custom object.
* @returns The replication listener settings object with filled with the ENV variables
*/
export declare const getInboxReplicationListenerSettings: (env?: Env) => ReplicationListenerSettings;
/**
* Loads the environment variables into the replication listener settings
* object. It supports reading an outbox specific setting or a general one.
* Please use the `getOutboxReplicationListenerEnvTemplate` functions to get a
* list of all the outbox relevant settings for the replication listener.
* @example
* TRX_DB_SCHEMA=trx_schema
* TRX_OUTBOX_DB_TABLE=outbox_table
* TRX_OUTBOX_DB_REPLICATION_SLOT=pg_transactional_outbox_slot
* @param env The process.env variable or a custom object.
* @returns The replication listener settings object with filled with the ENV variables
*/
export declare const getOutboxReplicationListenerSettings: (env?: Env) => ReplicationListenerSettings;
/**
* Shows the available env variables and their default values for the inbox
* listener with the replication 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 getInboxReplicationListenerEnvTemplate: (defaultOverrides?: Record<string, string>) => string;
/**
* Shows the available env variables and their default values for the outbox
* listener with the replication 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 getOutboxReplicationListenerEnvTemplate: (defaultOverrides?: Record<string, string>) => string;
//# sourceMappingURL=config.d.ts.map