/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import { Transactionable } from '@nocobase/database';
import type PluginWorkflowServer from './Plugin';
import type { ExecutionModel } from './types';
export default class ExecutionTimeoutManager {
    private readonly plugin;
    private readonly timers;
    private scanTimer;
    private nextExpiresAtTimer;
    private nextExpiresAt;
    private scanning;
    private stopped;
    constructor(plugin: PluginWorkflowServer);
    getTimeout(execution: ExecutionModel): number;
    getExpiresAt(execution: ExecutionModel, startedAt: Date): Date;
    load(): Promise<void>;
    unload(): Promise<void>;
    isExpired(execution: ExecutionModel, now?: Date): boolean;
    getRemainingMs(execution: ExecutionModel, now?: Date): number;
    abort(execution: ExecutionModel, options?: Transactionable): Promise<boolean>;
    abortExecutionIfExpired(execution: ExecutionModel, options?: Transactionable): Promise<boolean>;
    private abortExecutionIfExpiredWithLock;
    clear(executionId: number | string): void;
    shouldContinue(execution: ExecutionModel, options?: Transactionable): Promise<boolean>;
    /**
     * Owner-only per-execution timer. Only call from code paths that have acquired
     * local execution ownership, such as Dispatcher/Processor processing paths.
     */
    scheduleExecutionTimeout(execution: ExecutionModel): void;
    invalidateNextExpiresAtIfMatches(expiresAt?: Date | null): void;
    private scanExpiredExecutions;
    private scheduleScan;
    private scheduleNextExpiresAtTimer;
    private scheduleNextExpiresAtIfEarlier;
    private handleNextExpiresAtTimeout;
    private clearNextExpiresAtTimer;
    private clearExecutionTimeout;
    private handleExecutionTimeout;
}
