import EventEmitter2 from 'eventemitter2';
import { ClientConfig } from 'pg';
import { AbstractPlugin } from './output-plugins/abstract.plugin.js';
export interface ReplicationClientConfig extends ClientConfig {
    replication: 'database';
}
export interface LogicalReplicationConfig {
    acknowledge?: {
        /**
         * If the value is false, acknowledge must be done manually.
         * Default: true
         */
        auto: boolean;
        /**
         * Acknowledge is performed every set time (sec). If 0, do not do it.
         * Default: 10
         */
        timeoutSeconds: 0 | 10 | number;
    };
    /**
     * Flow control (backpressure) configuration.
     * When enabled, the stream will be paused until the data handler completes,
     * preventing memory overflow when processing is slower than the incoming message rate.
     */
    flowControl?: {
        /**
         * If true, pause the stream until the data handler completes.
         * This enables backpressure support for async handlers.
         * Default: false
         */
        enabled: boolean;
    };
}
export interface LogicalReplicationService {
    on(event: 'error', listener: (err: Error) => void): this;
    on(event: 'data', listener: (lsn: string, log: any) => Promise<void> | void): this;
    on(event: 'start', listener: () => Promise<void> | void): this;
    on(event: 'acknowledge', listener: (lsn: string) => Promise<void> | void): this;
    on(event: 'heartbeat', listener: (lsn: string, timestamp: number, shouldRespond: boolean) => Promise<void> | void): this;
}
export declare class LogicalReplicationService extends EventEmitter2 implements LogicalReplicationService {
    readonly clientConfig: ClientConfig;
    readonly config: LogicalReplicationConfig;
    constructor(clientConfig: ClientConfig, config?: Partial<LogicalReplicationConfig>);
    private _lastLsn;
    lastLsn(): string;
    private _client;
    private _connection;
    private client;
    private _stop;
    isStop(): boolean;
    private _messageQueue;
    private _processing;
    stop(): Promise<this>;
    destroy(): Promise<this>;
    subscribe(plugin: AbstractPlugin, slotName: string): Promise<this>;
    subscribe(plugin: AbstractPlugin, slotName: string, uptoLsn: string): Promise<this>;
    private _acknowledge;
    /**
     * Process messages in the queue sequentially with backpressure support.
     * Pauses the stream while processing and resumes when the queue is empty.
     */
    private _processQueue;
    private lastStandbyStatusUpdatedTime;
    private checkStandbyStatusTimer;
    private checkStandbyStatus;
    /**
     * @param lsn
     * @param ping Request server to respond
     */
    acknowledge(lsn: string, ping?: boolean): Promise<boolean>;
}
