from __future__ import annotations import os import platform from dataclasses import dataclass def detect_os_type() -> str: system_name = platform.system().upper() if system_name.startswith("WIN"): return "WINDOWS" if system_name.startswith("LINUX"): return "LINUX" return system_name or "UNKNOWN" @dataclass(slots=True) class Settings: backend_base_url: str edge_id: str edge_name: str edge_hostname: str edge_os_type: str edge_agent_version: str edge_access_token: str | None poll_interval_ms: int heartbeat_interval_ms: int request_timeout_ms: int default_health_check_timeout_ms: int def get_settings() -> Settings: return Settings( backend_base_url=os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:8000").rstrip("/"), edge_id=os.getenv("EDGE_ID", "edge-shanghai-001"), edge_name=os.getenv("EDGE_NAME", "edge-agent-demo"), edge_hostname=os.getenv("EDGE_HOSTNAME", platform.node() or "localhost"), edge_os_type=os.getenv("EDGE_OS_TYPE", detect_os_type()), edge_agent_version=os.getenv("EDGE_AGENT_VERSION", "0.1.0"), edge_access_token=os.getenv("EDGE_ACCESS_TOKEN"), poll_interval_ms=int(os.getenv("POLL_INTERVAL_MS", "3000")), heartbeat_interval_ms=int(os.getenv("HEARTBEAT_INTERVAL_MS", "10000")), request_timeout_ms=int(os.getenv("REQUEST_TIMEOUT_MS", "5000")), default_health_check_timeout_ms=int(os.getenv("DEFAULT_HEALTH_CHECK_TIMEOUT_MS", "3000")), )