ADK-gateway/backend/app/config.py
2026-08-05 16:33:27 +08:00

55 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""应用配置:通过环境变量 / .env 读取。"""
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
# 项目根目录backend/ 的上一级)
PROJECT_ROOT = Path(__file__).resolve().parents[2]
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=str(PROJECT_ROOT / ".env"),
env_file_encoding="utf-8",
extra="ignore",
)
# Redis
redis_url: str = "redis://localhost:6379/0"
# 网关服务
host: str = "0.0.0.0"
port: int = 8000
# 心跳保活参数(秒)
heartbeat_scan_interval: int = 60
agent_heartbeat_timeout: int = 120
agent_heartbeat_expected: int = 10
# 调度参数(秒)
dispatch_interval: int = 2
task_timeout_check_interval: int = 5
# 任务默认超时(秒)
default_task_timeout: int = 3600
# 任务数据保留 TTL
task_ttl: int = 86400
# 日志级别
log_level: str = "INFO"
# 认证CLI 提交任务 / Agent 注册时必须携带的密码
gateway_auth: str = "dev-gateway-auth"
# 认证Admin 后台管理接口必须携带的密码(与协议层 gateway_auth 分离)
admin_auth: str = "dev-admin-auth"
# 分布式锁相关
lock_timeout: int = 30
# 最大并发调度轮次
dispatch_batch_size: int = 20
settings = Settings()