import { PgBoss } from 'pg-boss'; import { JobInfo } from '../job.info.js'; import { JobMonitor, JobQueryOptions, JobQueueStats, JobRedriveOptions } from '../job.monitor.js'; import { PgBossConnectionProvider } from './pgboss.connection.provider.js'; /** * pg-boss implementation of the {@link JobMonitor} interface. * * Provides the operator-side view of pg-boss queues — depth/health stats, job * enumeration, and dead-letter remediation (redrive, discard, retry) — on top of * pg-boss's native `getQueue`, `findJobs`, `redrive`, `deleteJob`, and `retry`. * * Like {@link PgBossJobBroker}, every operation sources its pg-boss `db` executor * from the injected {@link PgBossConnectionProvider}, so a remediation action can * participate in a surrounding transaction when a request-scoped override supplies * a transaction-bound executor. Unlike the broker, the monitor does not consult * the job registry: it works on any queue name, including an unregistered * dead-letter sink. * * @example * ```typescript * const monitor = new PgBossJobMonitor(pgboss, new PgBossConnectionProvider()); * * const stats = await monitor.getQueueStats('charge.webhook.dead'); * if (stats && stats.total > 0) { * await monitor.redrive('charge.webhook.dead', { limit: 100 }); * } * ``` */ export declare class PgBossJobMonitor extends JobMonitor { private readonly pgboss; private readonly connectionProvider; /** * Creates a new PgBossJobMonitor instance. * * @param pgboss - The pg-boss instance to use for queue operations. * @param connectionProvider - Supplies the pg-boss `db` executor for each * operation; the default returns `undefined` (pg-boss's own pool), * while a request-scoped override enables transactional remediation. */ constructor(pgboss: PgBoss, connectionProvider: PgBossConnectionProvider); /** * Reports the depth and health of a queue by reading pg-boss's cached queue * counters. * * @param name - The queue name to inspect. * @returns The {@link JobQueueStats}, or `null` if the queue does not exist. */ getQueueStats(name: string): Promise; /** * Lists jobs retained in a queue, mapping pg-boss's records down to the * backend-agnostic {@link JobInfo} shape. * * @typeParam Payload - The type of the job payloads. * @param name - The queue name to list. * @param options - Optional {@link JobQueryOptions} filters. * @returns The matching jobs (empty if none, or if the queue does not exist). */ listJobs(name: string, options?: JobQueryOptions): Promise[]>; /** * Moves dead-lettered jobs back into circulation via pg-boss `redrive`. * * @param name - The (dead-letter) queue to drain. * @param options - Optional {@link JobRedriveOptions}. * @returns The number of jobs moved. */ redrive(name: string, options?: JobRedriveOptions): Promise; /** * Permanently deletes one or more jobs from a queue. * * @param name - The queue name the jobs live in. * @param id - A single job id, or an array of ids, to delete. */ deleteJob(name: string, id: string | string[]): Promise; /** * Re-attempts one or more failed jobs in place via pg-boss `retry`. * * @param name - The queue name the jobs live in. * @param id - A single job id, or an array of ids, to retry. */ retryJob(name: string, id: string | string[]): Promise; } //# sourceMappingURL=pgboss.job.monitor.d.ts.map