import { Pool } from "pg";
import { JobStorage } from "./base-storage";
import { Job, JobStatus } from "../types";
export interface PostgreSQLStorage extends JobStorage {
    acquireNextJob(): Promise<Job | null>;
    completeJob(jobId: string, result: any): Promise<void>;
    failJob(jobId: string, error: string): Promise<void>;
}
/**
 * PostgreSQL storage adapter for JobQueue
 *
 * This storage adapter uses PostgreSQL to store jobs, making it suitable
 * for distributed environments with multiple instances/processes.
 */
export declare class PostgreSQLJobStorage implements PostgreSQLStorage {
    private readonly pool;
    private readonly tableName;
    private initialized;
    private readonly logging;
    private readonly staleJobTimeout;
    /**
     * Create a new PostgreSQL job storage
     *
     * @param pool - A pg Pool instance
     * @param options - Configuration options
     */
    constructor(pool: Pool, options?: {
        tableName?: string;
        logging?: boolean;
        staleJobTimeout?: number;
    });
    /**
     * Initialize the database tables if they don't exist
     */
    initialize(): Promise<void>;
    /**
     * Save a job to PostgreSQL
     */
    saveJob(job: Job): Promise<void>;
    /**
     * Get a job by ID
     */
    getJob(id: string): Promise<Job | null>;
    /**
     * Get jobs by status
     */
    getJobsByStatus(status: JobStatus): Promise<Job[]>;
    /**
     * Update a job
     */
    updateJob(job: Job): Promise<void>;
    /**
     * Acquire the next pending job
     * @returns The next pending job, or null if no pending jobs are available
     */
    acquireNextJob(): Promise<Job | null>;
    /**
     * Complete a job
     * @param jobId - The ID of the job to complete
     * @param result - The result of the job
     */
    completeJob(jobId: string, result: any): Promise<void>;
    /**
     * Fail a job
     * @param jobId - The ID of the job to fail
     * @param error - The error message
     */
    failJob(jobId: string, error: string): Promise<void>;
    /**
     * Map a database row to a Job object
     * @param row - The database row to map
     * @returns The mapped Job object
     */
    private mapRowToJob;
}
//# sourceMappingURL=postgresql-storage.d.ts.map