export const CLOSED_CONNECTION: unique symbol;
/**
 * PendingCheckout type.
 * @typedef {object} PendingCheckout
 * @property {import("../../configuration-types.js").DatabaseConfigurationType} databaseConfig - Resolved database configuration needed by the checkout.
 * @property {number} enqueuedAt - Timestamp when the checkout started waiting.
 * @property {import("./base.js").ConnectionCheckoutOptions} options - Checkout options.
 * @property {string} reuseKey - Database configuration reuse key needed by the checkout.
 * @property {(connection: import("../drivers/base.js").default) => void} resolve - Resolves with an activated connection.
 * @property {(error: Error) => void} reject - Rejects when checkout cannot complete.
 */
export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends BasePool {
    /**
     * Global fallback connections keyed by configuration instance and pool identifier.
     * @type {WeakMap<import("../../configuration.js").default, Record<string, import("../drivers/base.js").default>>}
     */
    static globalConnections: WeakMap<import("../../configuration.js").default, Record<string, import("../drivers/base.js").default>>;
    /**
     * Replaces all globally registered fallback connections.
     * @param {Record<string, import("../drivers/base.js").default>} [connections] - Connections.
     * @param {import("../../configuration.js").default} [configuration] - Configuration instance.
     * @returns {void} - No return value.
     */
    static setGlobalConnections(connections?: Record<string, import("../drivers/base.js").default>, configuration?: import("../../configuration.js").default): void;
    /**
     * Clears globally registered fallback connections for all configurations or a single configuration.
     * @param {import("../../configuration.js").default} [configuration] - Configuration instance.
     * @returns {void} - No return value.
     */
    static clearGlobalConnections(configuration?: import("../../configuration.js").default): void;
    asyncLocalStorage: AsyncLocalStorage<any>;
    /**
     * When set, returned by getCurrentContextConnection when no async context exists.
     * Used by the test runner to share a connection between test code and HTTP handlers
     * running in the same process (in-process test server mode).
     * @type {import("../drivers/base.js").default | undefined}
     */
    _testSharedConnection: import("../drivers/base.js").default | undefined;
    /**
     * Connections.
      @type {import("../drivers/base.js").default[]} */
    connections: import("../drivers/base.js").default[];
    /**
     * Connections in use.
      @type {Record<number, import("../drivers/base.js").default>} */
    connectionsInUse: Record<number, import("../drivers/base.js").default>;
    /**
     * Pending checkouts.
      @type {PendingCheckout[]} */
    pendingCheckouts: PendingCheckout[];
    /**
     * Connections being spawned.
      @type {number} */
    connectionsBeingSpawned: number;
    /**
     * Pending checkout drain promise.
      @type {Promise<void> | undefined} */
    pendingCheckoutDrainPromise: Promise<void> | undefined;
    /**
     * Idle connection reaper timer.
      @type {ReturnType<typeof setTimeout> | undefined} */
    idleConnectionReaperTimer: ReturnType<typeof setTimeout> | undefined;
    /**
     * In-flight connection-close promises. The idle reaper is armed on check-in
     * and runs fire-and-forget when its timer fires, so a scheduled reap can be
     * closing a connection while an explicit `reapIdleConnections()` (or
     * `clearIdleConnectionReaperTimer()`) runs. Tracking the in-flight closes lets
     * those callers await them, so once a reap resolves the connections it
     * expired are fully closed instead of half-closed mid-`close()`.
     * @type {Set<Promise<void>>}
     */
    inflightConnectionCloses: Set<Promise<void>>;
    /**
     * In-flight close promise per connection, so concurrent closes of the same
     * connection await the same close rather than closing the driver handle twice.
     * @type {WeakMap<object, Promise<void>>}
     */
    connectionClosePromises: WeakMap<object, Promise<void>>;
    idSeq: number;
    _withoutCurrentConnectionContext: (callback: () => unknown) => unknown;
    /**
     * Runs checkin.
     * @param {import("../drivers/base.js").default} connection - Database connection instance.
     * @returns {Promise<void>} - Resolves when the connection is checked in or closed.
     */
    checkin(connection: import("../drivers/base.js").default): Promise<void>;
    /**
     * Runs close checked out connection after checkin failure.
     * @param {import("../drivers/base.js").default} connection - Connection that failed check-in cleanup.
     * @param {number | undefined} id - Connection checkout id.
     * @param {?} originalError - Error that caused check-in cleanup to fail.
     * @returns {Promise<void>} - Resolves when cleanup has been attempted.
     */
    closeCheckedOutConnectionAfterCheckinFailure(connection: import("../drivers/base.js").default, id: number | undefined, originalError: unknown): Promise<void>;
    /**
     * Runs untrack connection in use.
     * @param {import("../drivers/base.js").default} connection - Connection being checked in.
     * @param {number | undefined} id - Connection checkout id.
     * @returns {void}
     */
    untrackConnectionInUse(connection: import("../drivers/base.js").default, id: number | undefined): void;
    /**
     * Runs handle checked in idle connection.
     * @returns {Promise<void>} - Resolves once idle reaping has been scheduled or run.
     */
    handleCheckedInIdleConnection(): Promise<void>;
    /**
     * Runs take idle connection for reuse key.
     * @param {string} reuseKey - Database configuration reuse key.
     * @param {object} [args] - Options.
     * @param {boolean} [args.includeOpenTransactions] - Whether connections with open transactions may be returned.
     * @returns {import("../drivers/base.js").default | undefined} - Matching idle connection.
     */
    takeIdleConnectionForReuseKey(reuseKey: string, { includeOpenTransactions }?: {
        includeOpenTransactions?: boolean | undefined;
    }): import("../drivers/base.js").default | undefined;
    /**
     * Runs connection matches reuse key.
     * @param {import("../drivers/base.js").default} connection - Connection.
     * @param {string} reuseKey - Database configuration reuse key.
     * @returns {boolean} - Whether the connection matches the reuse key.
     */
    connectionMatchesReuseKey(connection: import("../drivers/base.js").default, reuseKey: string): boolean;
    /**
     * Runs activate connection.
     * @param {import("../drivers/base.js").default} connection - Connection.
     * @param {import("./base.js").ConnectionCheckoutOptions} [options] - Checkout options.
     * @returns {Promise<import("../drivers/base.js").default>} - Activated connection.
     */
    activateConnection(connection: import("../drivers/base.js").default, options?: import("./base.js").ConnectionCheckoutOptions): Promise<import("../drivers/base.js").default>;
    /**
     * Runs max connections.
     * @returns {number | undefined} - Configured max live connections.
     */
    maxConnections(): number | undefined;
    /**
     * Runs valid max connections.
     * @param {?} value - Candidate max connection count.
     * @returns {value is number} - Whether the value is a valid max connection count.
     */
    validMaxConnections(value: unknown): value is number;
    /**
     * Runs live connection count.
     * @returns {number} - Number of live and in-progress connections.
     */
    liveConnectionCount(): number;
    /**
     * Runs can spawn connection.
     * @returns {boolean} - Whether a new connection can be spawned.
     */
    canSpawnConnection(): boolean;
    /**
     * Runs spawn connection for checkout.
     * @param {import("../../configuration-types.js").DatabaseConfigurationType} databaseConfig - Resolved database config for the checkout.
     * @param {string} reuseKey - Database configuration reuse key for the checkout.
     * @returns {Promise<import("../drivers/base.js").default>} - Spawned connection.
     */
    spawnConnectionForCheckout(databaseConfig: import("../../configuration-types.js").DatabaseConfigurationType, reuseKey: string): Promise<import("../drivers/base.js").default>;
    /**
     * Runs wait for checkout.
     * @param {import("../../configuration-types.js").DatabaseConfigurationType} databaseConfig - Resolved database config for the checkout.
     * @param {string} reuseKey - Database configuration reuse key.
     * @param {import("./base.js").ConnectionCheckoutOptions} [options] - Checkout options.
     * @returns {Promise<import("../drivers/base.js").default>} - Resolves with an activated connection.
     */
    waitForCheckout(databaseConfig: import("../../configuration-types.js").DatabaseConfigurationType, reuseKey: string, options?: import("./base.js").ConnectionCheckoutOptions): Promise<import("../drivers/base.js").default>;
    /**
     * Runs drain pending checkouts.
     * @returns {Promise<void>} - Resolves when pending checkouts have been drained as far as possible.
     */
    drainPendingCheckouts(): Promise<void>;
    /**
     * Runs drain pending checkouts actual.
     * @returns {Promise<void>} - Resolves when pending checkouts have been drained as far as possible.
     */
    drainPendingCheckoutsActual(): Promise<void>;
    /**
     * Runs resolve pending checkout with matching idle connection.
     * @returns {Promise<boolean>} - Whether a pending checkout was resolved with an idle connection.
     */
    resolvePendingCheckoutWithMatchingIdleConnection(): Promise<boolean>;
    /**
     * Runs close idle connection for pending checkout capacity.
     * @param {PendingCheckout} checkout - Checkout waiting for a connection.
     * @returns {Promise<boolean>} - Whether an idle connection was closed to free capacity.
     */
    closeIdleConnectionForPendingCheckoutCapacity(checkout: PendingCheckout): Promise<boolean>;
    /**
     * Runs find idle connection for reuse key.
     * @param {string} reuseKey - Database configuration reuse key.
     * @returns {import("../drivers/base.js").default | undefined} - Matching idle connection, if present.
     */
    findIdleConnectionForReuseKey(reuseKey: string): import("../drivers/base.js").default | undefined;
    /**
     * Runs idle connection for pending checkout.
     * @param {PendingCheckout} checkout - Checkout waiting for a connection.
     * @returns {Promise<import("../drivers/base.js").default | undefined>} - Matching idle connection, if one can be reused.
     */
    idleConnectionForPendingCheckout(checkout: PendingCheckout): Promise<import("../drivers/base.js").default | undefined>;
    /**
     * Runs spawn and resolve pending checkout.
     * @param {PendingCheckout} checkout - Checkout request to resolve.
     * @returns {Promise<void>} - Resolves when the checkout has been handled.
     */
    spawnAndResolvePendingCheckout(checkout: PendingCheckout): Promise<void>;
    /**
     * Runs resolve pending checkout.
     * @param {PendingCheckout} checkout - Checkout request to resolve.
     * @param {import("../drivers/base.js").default} connection - Connection to activate.
     * @returns {Promise<void>} - Resolves when the checkout has been handled.
     */
    resolvePendingCheckout(checkout: PendingCheckout, connection: import("../drivers/base.js").default): Promise<void>;
    /**
     * Runs close one idle connection for capacity.
     * @returns {Promise<boolean>} - Whether an idle connection was closed to free capacity.
     */
    closeOneIdleConnectionForCapacity(): Promise<boolean>;
    /**
     * Runs current fallback connection or fail.
     * @returns {import("../drivers/base.js").default} - Fallback connection, if present.
     */
    currentFallbackConnectionOrFail(): import("../drivers/base.js").default;
    /**
     * Runs ensure connection is in use.
     * @param {number} id - Checked-out connection id.
     * @returns {void}
     */
    ensureConnectionIsInUse(id: number): void;
    /**
     * Registers a fallback connection for this pool identifier that will be used when no async context is available.
     * @param {import("../drivers/base.js").default} connection - Connection.
     * @returns {void} - No return value.
     */
    setGlobalConnection(connection: import("../drivers/base.js").default): void;
    /**
     * Set a shared connection for test mode so that HTTP handlers running
     * in the same process can reuse the test runner's database connection.
     * @param {import("../drivers/base.js").default} connection - Shared connection.
     * @returns {void}
     */
    setTestSharedConnection(connection: import("../drivers/base.js").default): void;
    /**
     * Runs clear test shared connection.
      @returns {void} */
    clearTestSharedConnection(): void;
    /**
     * Runs debug connection snapshots.
     * @param {number} now - Current timestamp.
     * @returns {{connections: Array<Record<string, ?>>, seenConnections: Set<import("../drivers/base.js").default>}} - Connection snapshots and seen set.
     */
    debugConnectionSnapshots(now: number): {
        connections: Array<Record<string, unknown>>;
        seenConnections: Set<import("../drivers/base.js").default>;
    };
    /**
     * Runs add in use debug connection snapshots.
     * @param {{connections: Array<Record<string, ?>>, now: number, seenConnections: Set<import("../drivers/base.js").default>}} args - Snapshot collection state.
     * @returns {void}
     */
    addInUseDebugConnectionSnapshots({ connections, now, seenConnections }: {
        connections: Array<Record<string, unknown>>;
        now: number;
        seenConnections: Set<import("../drivers/base.js").default>;
    }): void;
    /**
     * Runs add idle debug connection snapshots.
     * @param {{connections: Array<Record<string, ?>>, now: number, seenConnections: Set<import("../drivers/base.js").default>}} args - Snapshot collection state.
     * @returns {void}
     */
    addIdleDebugConnectionSnapshots({ connections, now, seenConnections }: {
        connections: Array<Record<string, unknown>>;
        now: number;
        seenConnections: Set<import("../drivers/base.js").default>;
    }): void;
    /**
     * Runs add fallback debug connection snapshots.
     * @param {{connections: Array<Record<string, ?>>, seenConnections: Set<import("../drivers/base.js").default>}} args - Snapshot collection state.
     * @returns {void}
     */
    addFallbackDebugConnectionSnapshots({ connections, seenConnections }: {
        connections: Array<Record<string, unknown>>;
        seenConnections: Set<import("../drivers/base.js").default>;
    }): void;
    /**
     * Runs add debug connection snapshot if unseen.
     * @param {{connection: import("../drivers/base.js").default | undefined, connections: Array<Record<string, ?>>, reapable?: boolean, seenConnections: Set<import("../drivers/base.js").default>, state: string}} args - Snapshot collection state.
     * @returns {void}
     */
    addDebugConnectionSnapshotIfUnseen({ connection, connections, reapable, seenConnections, state }: {
        connection: import("../drivers/base.js").default | undefined;
        connections: Array<Record<string, unknown>>;
        reapable?: boolean;
        seenConnections: Set<import("../drivers/base.js").default>;
        state: string;
    }): void;
    /**
     * Runs pending checkout debug snapshots.
     * @param {number} now - Current timestamp.
     * @returns {Array<Record<string, ?>>} - Pending checkout snapshots.
     */
    pendingCheckoutDebugSnapshots(now: number): Array<Record<string, unknown>>;
    /**
     * Runs get global connection.
     * @returns {import("../drivers/base.js").default | undefined} - The global connection.
     */
    getGlobalConnection(): import("../drivers/base.js").default | undefined;
    /**
     * Runs get global connection for identifier.
     * @returns {import("../drivers/base.js").default | undefined} - The global connection for this pool identifier.
     */
    getGlobalConnectionForIdentifier(): import("../drivers/base.js").default | undefined;
    /**
     * Runs clear global connection for identifier.
     * @returns {void} - No return value.
     */
    clearGlobalConnectionForIdentifier(): void;
    /**
     * Runs idle timeout millis.
     * @returns {number | null} - Idle timeout in milliseconds, or null when disabled.
     */
    idleTimeoutMillis(): number | null;
    /**
     * Runs valid idle timeout millis.
     * @param {?} value - Candidate idle timeout value.
     * @returns {value is number} - Whether the value is a valid idle timeout.
     */
    validIdleTimeoutMillis(value: unknown): value is number;
    /**
     * Runs schedule idle connection reaper.
      @returns {void} */
    scheduleIdleConnectionReaper(): void;
    /**
     * Runs has idle connections to reap.
     * @returns {boolean} - Whether an idle reaper timer should be scheduled.
     */
    hasIdleConnectionsToReap(): boolean;
    /**
     * Runs next idle connection reap delay.
     * @param {number} idleTimeoutMillis - Idle timeout in milliseconds.
     * @returns {number} - Delay before the next reap.
     */
    nextIdleConnectionReapDelay(idleTimeoutMillis: number): number;
    /**
     * Closes idle checked-in connections that have exceeded the configured timeout.
     * @returns {Promise<void>} - Resolves when complete.
     */
    reapIdleConnections(): Promise<void>;
    /**
     * Runs close expired idle connections.
     * @param {import("../drivers/base.js").default[]} expiredConnections - Connections to close.
     * @returns {Promise<void>} - Resolves when closed.
     */
    closeExpiredIdleConnections(expiredConnections: import("../drivers/base.js").default[]): Promise<void>;
    /**
     * Runs await inflight connection closes.
     * @returns {Promise<void>} - Resolves once in-flight connection closes settle.
     */
    awaitInflightConnectionCloses(): Promise<void>;
    /**
     * Runs classify idle connections for reaping.
     * @param {{idleTimeoutMillis: number, now: number}} args - Reaper classification inputs.
     * @returns {{expiredConnections: import("../drivers/base.js").default[], keptConnections: import("../drivers/base.js").default[]}} - Classified idle connections.
     */
    classifyIdleConnectionsForReaping({ idleTimeoutMillis, now }: {
        idleTimeoutMillis: number;
        now: number;
    }): {
        expiredConnections: import("../drivers/base.js").default[];
        keptConnections: import("../drivers/base.js").default[];
    };
    /**
     * Runs classify idle connection for reaping.
     * @param {{connection: import("../drivers/base.js").default, expiredConnections: import("../drivers/base.js").default[], idleTimeoutMillis: number, keptConnections: import("../drivers/base.js").default[], now: number}} args - Classification state.
     * @returns {void}
     */
    classifyIdleConnectionForReaping({ connection, expiredConnections, idleTimeoutMillis, keptConnections, now }: {
        connection: import("../drivers/base.js").default;
        expiredConnections: import("../drivers/base.js").default[];
        idleTimeoutMillis: number;
        keptConnections: import("../drivers/base.js").default[];
        now: number;
    }): void;
    /**
     * Runs connection is closed.
     * @param {import("../drivers/base.js").default} connection - Connection to inspect.
     * @returns {boolean} - Whether the connection is marked closed.
     */
    connectionIsClosed(connection: import("../drivers/base.js").default): boolean;
    /**
     * Runs idle connection expired.
     * @param {{connection: import("../drivers/base.js").default, idleTimeoutMillis: number, now: number}} args - Expiry inputs.
     * @returns {boolean} - Whether the idle connection expired.
     */
    idleConnectionExpired({ connection, idleTimeoutMillis, now }: {
        connection: import("../drivers/base.js").default;
        idleTimeoutMillis: number;
        now: number;
    }): boolean;
    /**
     * Runs connection has open transaction.
     * @param {import("../drivers/base.js").default} connection - Connection to inspect.
     * @returns {boolean} - Whether the connection has an open transaction.
     */
    connectionHasOpenTransaction(connection: import("../drivers/base.js").default): boolean;
    /**
     * Rolls back any transaction a previous holder left open before a connection
     * re-enters the idle pool. A connection returned to the pool with an open
     * transaction would otherwise be handed to an unrelated checkout, whose
     * startTransaction() then fails with "A transaction is already running" and
     * poisons every following caller that reuses it.
     * @param {import("../drivers/base.js").default} connection - Connection being checked in.
     * @returns {Promise<void>} - Resolves when the connection holds no open transaction.
     */
    rollbackLeftOpenTransaction(connection: import("../drivers/base.js").default): Promise<void>;
    /**
     * Runs close connection.
     * @param {import("../drivers/base.js").default} connection - Connection to close.
     * @returns {Promise<void>} - Resolves when complete.
     */
    closeConnection(connection: import("../drivers/base.js").default): Promise<void>;
    /**
     * Runs clear idle connection reaper timer.
      @returns {void} */
    clearIdleConnectionReaperTimer(): void;
    /**
     * Runs reject pending checkouts.
     * @param {Error} error - Error to reject pending checkouts with.
     * @returns {void}
     */
    rejectPendingCheckouts(error: Error): void;
}
/**
 * PendingCheckout type.
 */
export type PendingCheckout = {
    /**
     * - Resolved database configuration needed by the checkout.
     */
    databaseConfig: import("../../configuration-types.js").DatabaseConfigurationType;
    /**
     * - Timestamp when the checkout started waiting.
     */
    enqueuedAt: number;
    /**
     * - Checkout options.
     */
    options: import("./base.js").ConnectionCheckoutOptions;
    /**
     * - Database configuration reuse key needed by the checkout.
     */
    reuseKey: string;
    /**
     * - Resolves with an activated connection.
     */
    resolve: (connection: import("../drivers/base.js").default) => void;
    /**
     * - Rejects when checkout cannot complete.
     */
    reject: (error: Error) => void;
};
import BasePool from "./base.js";
import { AsyncLocalStorage } from "async_hooks";
//# sourceMappingURL=async-tracked-multi-connection.d.ts.map