import { Pool } from "pg"; import { makeWorkerPresetWorkerOptions } from "./config"; import { AddJobFunction, AddJobsFunction, EnhancedWithPgClient, PromiseOrDirect, RunnerOptions, RunOnceOptions, SharedOptions, WithPgClient, WorkerEventMap, WorkerOptions, WorkerPluginContext, WorkerSharedOptions, WorkerUtilsOptions } from "./interfaces"; import { LogScope } from "./logger"; export declare const BREAKING_MIGRATIONS: number[]; export type ResolvedWorkerPreset = GraphileConfig.ResolvedPreset & { worker: GraphileConfig.WorkerOptions & ReturnType; }; export interface CompiledSharedOptions extends WorkerPluginContext { /** * DO NOT USE THIS! As we move over to presets this will be removed. * * @internal */ _rawOptions: T; } interface ProcessSharedOptionsSettings { scope?: LogScope; } export declare function processSharedOptions(options: T, { scope }?: ProcessSharedOptionsSettings): CompiledSharedOptions; export type Releasers = Array<() => void | Promise>; export declare function assertPool(compiledSharedOptions: CompiledSharedOptions, releasers: Releasers): Promise; export type Release = () => PromiseOrDirect; export declare function withReleasers(callback: (releasers: Releasers, release: Release) => Promise): Promise; interface ProcessOptionsExtensions { pgPool: Pool; withPgClient: EnhancedWithPgClient; addJob: AddJobFunction; addJobs: AddJobsFunction; releasers: Releasers; } export interface CompiledOptions extends CompiledSharedOptions, ProcessOptionsExtensions { } type CompiledOptionsAndRelease = [ compiledOptions: CompiledOptions, release: (error?: Error) => PromiseOrDirect ]; export declare const getUtilsAndReleasersFromOptions: (options: RunnerOptions, settings?: ProcessSharedOptionsSettings) => Promise; export declare function tryParseJson(json: string | null | undefined): T | null; /** @see {@link https://www.postgresql.org/docs/current/mvcc-serialization-failure-handling.html} */ export declare const RETRYABLE_ERROR_CODES: Record | undefined>; export declare function makeEnhancedWithPgClient(withPgClient: WithPgClient | EnhancedWithPgClient): EnhancedWithPgClient; export declare const sleep: (ms: number) => Promise; export declare function coerceError(err: unknown): Error & { code?: unknown; }; export declare function isPromiseLike(v: PromiseLike | T): v is PromiseLike; export interface RetryOptions { maxAttempts: number; /** Minimum delay between attempts (milliseconds); can actually be half this due to jitter */ minDelay: number; /** Maximum delay between attempts (milliseconds) - can actually be 1.5x this due to jitter */ maxDelay: number; /** `multiplier ^ attempts` */ multiplier: number; } export declare function calculateDelay(previousAttempts: number, retryOptions: RetryOptions): number; export declare function safeEmit(ctx: WorkerPluginContext, eventName: TEvent, payload: WorkerEventMap[TEvent]): void; export {};