package cn.nianxx.thhotel.integrations.ai.superagent.service.impl;

import java.time.Duration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * AgentBus SourceMessage 自动分发 SuperAgent 配置。生产默认关闭，由环境变量显式开启。
 */
@Component
@ConfigurationProperties(prefix = "agentbus.superagent-dispatch")
public class SuperAgentDispatchProperties {

    /** 是否在 AgentBus 捕获成功后创建 SuperAgent dispatch run。 */
    private boolean enabled = false;
    /** 是否启用后台 worker 处理待分发记录。 */
    private boolean workerEnabled = false;
    /** 单次 worker 最多抢占记录数。 */
    private int batchSize = 10;
    /** 单条 dispatch 最大尝试次数。 */
    private int maxAttempts = 3;
    /** worker 抢占锁有效时长。 */
    private Duration lockTtl = Duration.ofMinutes(5);
    /** 首次失败后的退避时长。 */
    private Duration initialBackoff = Duration.ofSeconds(30);
    /** 失败退避最大时长。 */
    private Duration maxBackoff = Duration.ofMinutes(15);
    /** 定时 worker 调度间隔毫秒。 */
    private long workerFixedDelayMs = 10000L;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isWorkerEnabled() {
        return workerEnabled;
    }

    public void setWorkerEnabled(boolean workerEnabled) {
        this.workerEnabled = workerEnabled;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }

    public int getMaxAttempts() {
        return maxAttempts;
    }

    public void setMaxAttempts(int maxAttempts) {
        this.maxAttempts = maxAttempts;
    }

    public Duration getLockTtl() {
        return lockTtl;
    }

    public void setLockTtl(Duration lockTtl) {
        this.lockTtl = lockTtl;
    }

    public Duration getInitialBackoff() {
        return initialBackoff;
    }

    public void setInitialBackoff(Duration initialBackoff) {
        this.initialBackoff = initialBackoff;
    }

    public Duration getMaxBackoff() {
        return maxBackoff;
    }

    public void setMaxBackoff(Duration maxBackoff) {
        this.maxBackoff = maxBackoff;
    }

    public long getWorkerFixedDelayMs() {
        return workerFixedDelayMs;
    }

    public void setWorkerFixedDelayMs(long workerFixedDelayMs) {
        this.workerFixedDelayMs = workerFixedDelayMs;
    }
}
