45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Runtime configuration loaded from environment variables.
|
|
|
|
Anything that varies between dev / staging / prod (storage URLs, queue
|
|
endpoints, auth secrets) lands here. Phase 0 only exposes the bare minimum
|
|
needed for `/health` and the app factory.
|
|
"""
|
|
|
|
from functools import lru_cache
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_prefix="PDFENGINE_",
|
|
env_file=".env",
|
|
extra="ignore",
|
|
)
|
|
|
|
environment: str = Field(default="dev", description="dev | staging | prod")
|
|
engine_available: bool = Field(
|
|
default=False,
|
|
description=(
|
|
"True once the pybind11 module in bindings/python/ is importable. "
|
|
"Phase 0 default is False — routes that need the engine return 501."
|
|
),
|
|
)
|
|
|
|
render_cache_enabled: bool = Field(default=True)
|
|
render_cache_max_entries: int = Field(default=256)
|
|
render_cache_max_bytes: int = Field(
|
|
default=536_870_912,
|
|
description="Max total bytes for the tile render cache. Set to 0 to disable byte cap."
|
|
)
|
|
render_cache_max_entry_bytes: int = Field(
|
|
default=8_388_608,
|
|
description="Max bytes for a single cache entry. Oversized tiles are rendered but not cached."
|
|
)
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_settings() -> Settings:
|
|
return Settings()
|