| 123456789101112131415161718192021222324252627282930313233 |
- import os
- from dataclasses import dataclass
- from depth_common import Settings
- @dataclass(frozen=True)
- class ApiConfig:
- sample_count: int
- frame_timeout_ms: int
- sample_timeout_sec: int
- max_saved_images: int
- request_log_max_len: int
- request_log_max_bytes: int
- request_log_backup_count: int
- api_host: str
- api_port: int
- settings: Settings
- @classmethod
- def from_env(cls) -> "ApiConfig":
- return cls(
- sample_count=int(os.getenv("SAMPLE_COUNT", "10")),
- frame_timeout_ms=int(os.getenv("FRAME_TIMEOUT_MS", "200")),
- sample_timeout_sec=int(os.getenv("SAMPLE_TIMEOUT_SEC", "8")),
- max_saved_images=int(os.getenv("MAX_SAVED_IMAGES", "1000")),
- request_log_max_len=int(os.getenv("REQUEST_LOG_MAX_LEN", "1000")),
- request_log_max_bytes=int(os.getenv("REQUEST_LOG_MAX_BYTES", str(20 * 1024 * 1024))),
- request_log_backup_count=int(os.getenv("REQUEST_LOG_BACKUP_COUNT", "10")),
- api_host=os.getenv("API_HOST", "127.0.0.1"),
- api_port=int(os.getenv("API_PORT", "8080")),
- settings=Settings.from_env(),
- )
|