64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
"""Hub configuration via environment variables."""
|
|
|
|
from functools import lru_cache
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Hub settings loaded from environment variables."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
frozen=True,
|
|
)
|
|
|
|
# Application
|
|
APP_NAME: str = Field(default="LetsBe Hub", description="Application name")
|
|
APP_VERSION: str = Field(default="0.1.0", description="Application version")
|
|
DEBUG: bool = Field(default=False, description="Debug mode")
|
|
|
|
# Database
|
|
DATABASE_URL: str = Field(
|
|
default="postgresql+asyncpg://hub:hub@db:5432/hub",
|
|
description="PostgreSQL connection URL"
|
|
)
|
|
DB_POOL_SIZE: int = Field(default=5, ge=1, le=20, description="Connection pool size")
|
|
DB_MAX_OVERFLOW: int = Field(default=10, ge=0, le=50, description="Max overflow connections")
|
|
DB_POOL_TIMEOUT: int = Field(default=30, ge=5, le=120, description="Pool timeout in seconds")
|
|
DB_POOL_RECYCLE: int = Field(default=1800, ge=300, le=7200, description="Connection recycle time")
|
|
|
|
# Admin authentication
|
|
ADMIN_API_KEY: str = Field(
|
|
default="change-me-in-production",
|
|
min_length=16,
|
|
description="Admin API key for management endpoints"
|
|
)
|
|
|
|
# Telemetry settings
|
|
TELEMETRY_RETENTION_DAYS: int = Field(
|
|
default=90,
|
|
ge=7,
|
|
le=365,
|
|
description="Days to retain telemetry data"
|
|
)
|
|
|
|
# Rate limiting for activation endpoint
|
|
ACTIVATION_RATE_LIMIT_PER_MINUTE: int = Field(
|
|
default=10,
|
|
ge=1,
|
|
le=100,
|
|
description="Max activation attempts per instance per minute"
|
|
)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
"""Get cached settings instance."""
|
|
return Settings()
|
|
|
|
|
|
settings = get_settings()
|