"""
数据缓冲平台 - 配置
"""
import os
from pathlib import Path
from dotenv import load_dotenv

# 加载 .env 文件
load_dotenv()

# 项目根目录
BASE_DIR = Path(__file__).resolve().parent.parent.parent

# 数据库路径
DB_PATH = Path(os.getenv(
    "BUFFER_DB_PATH",
    str(Path(__file__).resolve().parent.parent / "data" / "buffer.db")
))

# 原始采集脚本路径
COLLECTOR_SCRIPT = os.getenv(
    "COLLECTOR_SCRIPT",
    str(BASE_DIR / "market_data_colector_platform" / "futures_data_collector.py")
)

# FastAPI 服务配置
HOST = os.getenv("BUFFER_HOST", "0.0.0.0")
PORT = int(os.getenv("BUFFER_PORT", "8600"))

# 数据缓存
CACHE_TTL_SECONDS = int(os.getenv("CACHE_TTL", "300"))  # 默认5分钟过期

# 并发采集
MAX_WORKERS = int(os.getenv("MAX_WORKERS", "2"))

# 日志
LOG_LEVEL = os.getenv("BUFFER_LOG_LEVEL", "INFO")

# 调度器
SCHEDULER_MAX_INSTANCES = 1  # 同一任务不允许重叠执行

# Redis 配置
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
REDIS_PORT = int(os.getenv("REDIS_PORT", "6379"))
REDIS_DB = int(os.getenv("REDIS_DB", "0"))
REDIS_PASSWORD = os.getenv("REDIS_PASSWORD", "")
REDIS_TTL_SECONDS = int(os.getenv("REDIS_TTL_SECONDS", "2592000"))  # 30 天

# MySQL 配置
MYSQL_HOST = os.getenv("MYSQL_HOST", "localhost")
MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
MYSQL_USER = os.getenv("MYSQL_USER", "root")
MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "")
MYSQL_DATABASE = os.getenv("MYSQL_DATABASE", "buffer_platform")
