package tech.easyflow.ai.documentimport.task;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.unit.DataSize;

import java.time.Duration;

/**
 * 文档批量导入容量与并发缺省配置。
 *
 * @author Codex
 * @since 2026-07-31
 */
@ConfigurationProperties(prefix = "easyflow.ai.document-import.bulk")
public class DocumentImportBulkProperties {

    private int maxFileCount = 2000;
    private DataSize maxTotalSize = DataSize.ofGigabytes(1);
    private DataSize maxFileSize = DataSize.ofMegabytes(100);
    private int uploadConcurrency = 3;
    private int parseMaxRunning = 2;
    private int splitMaxRunning = 2;
    private int indexMaxRunning = 2;
    private int perBatchParseMaxRunning = 2;
    private int pendingDispatchBatchSize = 100;
    private Duration pendingDispatchInterval = Duration.ofSeconds(2);
    private Duration pendingRedispatchDelay = Duration.ofSeconds(5);
    private Duration pendingTimeout = Duration.ofHours(24);
    private Duration parseSubmitTimeout = Duration.ofSeconds(120);
    private Duration interruptionTimeout = Duration.ofMinutes(10);
    private int maxTaskAttempts = 3;

    public int getMaxFileCount() {
        return maxFileCount;
    }

    public void setMaxFileCount(int maxFileCount) {
        this.maxFileCount = maxFileCount;
    }

    public DataSize getMaxTotalSize() {
        return maxTotalSize;
    }

    public void setMaxTotalSize(DataSize maxTotalSize) {
        this.maxTotalSize = maxTotalSize;
    }

    public DataSize getMaxFileSize() {
        return maxFileSize;
    }

    public void setMaxFileSize(DataSize maxFileSize) {
        this.maxFileSize = maxFileSize;
    }

    public int getUploadConcurrency() {
        return uploadConcurrency;
    }

    public void setUploadConcurrency(int uploadConcurrency) {
        this.uploadConcurrency = uploadConcurrency;
    }

    public int getParseMaxRunning() {
        return parseMaxRunning;
    }

    public void setParseMaxRunning(int parseMaxRunning) {
        this.parseMaxRunning = parseMaxRunning;
    }

    /**
     * 获取全局分块任务并发上限。
     *
     * @return 分块任务并发上限
     */
    public int getSplitMaxRunning() {
        return splitMaxRunning;
    }

    /**
     * 设置全局分块任务并发上限。
     *
     * @param splitMaxRunning 分块任务并发上限
     */
    public void setSplitMaxRunning(int splitMaxRunning) {
        this.splitMaxRunning = splitMaxRunning;
    }

    public int getIndexMaxRunning() {
        return indexMaxRunning;
    }

    public void setIndexMaxRunning(int indexMaxRunning) {
        this.indexMaxRunning = indexMaxRunning;
    }

    public int getPerBatchParseMaxRunning() {
        return perBatchParseMaxRunning;
    }

    public void setPerBatchParseMaxRunning(int perBatchParseMaxRunning) {
        this.perBatchParseMaxRunning = perBatchParseMaxRunning;
    }

    public int getPendingDispatchBatchSize() {
        return pendingDispatchBatchSize;
    }

    public void setPendingDispatchBatchSize(int pendingDispatchBatchSize) {
        this.pendingDispatchBatchSize = pendingDispatchBatchSize;
    }

    public Duration getPendingDispatchInterval() {
        return pendingDispatchInterval;
    }

    public void setPendingDispatchInterval(Duration pendingDispatchInterval) {
        this.pendingDispatchInterval = pendingDispatchInterval;
    }

    public Duration getPendingRedispatchDelay() {
        return pendingRedispatchDelay;
    }

    public void setPendingRedispatchDelay(Duration pendingRedispatchDelay) {
        this.pendingRedispatchDelay = pendingRedispatchDelay;
    }

    /**
     * 获取待处理任务最长排队时间。
     *
     * @return 最长排队时间
     */
    public Duration getPendingTimeout() {
        return pendingTimeout;
    }

    /**
     * 设置待处理任务最长排队时间。
     *
     * @param pendingTimeout 最长排队时间
     */
    public void setPendingTimeout(Duration pendingTimeout) {
        this.pendingTimeout = pendingTimeout;
    }

    /**
     * 获取解析服务任务提交超时时间。
     *
     * @return 任务提交超时时间
     */
    public Duration getParseSubmitTimeout() {
        return parseSubmitTimeout;
    }

    /**
     * 设置解析服务任务提交超时时间。
     *
     * @param parseSubmitTimeout 任务提交超时时间
     */
    public void setParseSubmitTimeout(Duration parseSubmitTimeout) {
        this.parseSubmitTimeout = parseSubmitTimeout;
    }

    public Duration getInterruptionTimeout() {
        return interruptionTimeout;
    }

    public void setInterruptionTimeout(Duration interruptionTimeout) {
        this.interruptionTimeout = interruptionTimeout;
    }

    /**
     * 获取单文件每阶段最大执行次数。
     *
     * @return 最大执行次数
     */
    public int getMaxTaskAttempts() {
        return maxTaskAttempts;
    }

    /**
     * 设置单文件每阶段最大执行次数。
     *
     * @param maxTaskAttempts 最大执行次数
     */
    public void setMaxTaskAttempts(int maxTaskAttempts) {
        this.maxTaskAttempts = maxTaskAttempts;
    }
}
