29 lines
864 B
Python
29 lines
864 B
Python
"""sidecar 运行配置。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SidecarConfig:
|
|
"""sidecar 配置项。"""
|
|
|
|
db_path: str = "data/tortoise.duckdb"
|
|
snapshot_ttl_seconds: int = 15
|
|
request_timeout_seconds: int = 8
|
|
|
|
|
|
def load_config() -> SidecarConfig:
|
|
"""
|
|
功能说明:从环境变量读取 sidecar 配置。
|
|
参数说明:无。
|
|
返回值说明:返回 SidecarConfig 配置对象。
|
|
注意事项:未配置环境变量时使用适合本地开发的默认值。
|
|
"""
|
|
return SidecarConfig(
|
|
db_path=os.getenv("TORTOISE_DUCKDB_PATH", "data/tortoise.duckdb"),
|
|
snapshot_ttl_seconds=int(os.getenv("TORTOISE_SNAPSHOT_TTL_SECONDS", "15")),
|
|
request_timeout_seconds=int(os.getenv("TORTOISE_REQUEST_TIMEOUT_SECONDS", "8")),
|
|
) |