2025-11-21 12:00:00 +00:00
|
|
|
"""Application configuration via pydantic-settings."""
|
|
|
|
|
|
2026-01-07 20:51:13 -05:00
|
|
|
from typing import Literal
|
|
|
|
|
|
2025-11-21 12:00:00 +00:00
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
|
"""Application settings loaded from environment variables."""
|
|
|
|
|
|
|
|
|
|
model_config = SettingsConfigDict(
|
|
|
|
|
env_file=".env",
|
|
|
|
|
env_file_encoding="utf-8",
|
|
|
|
|
case_sensitive=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
|
database_url: str
|
|
|
|
|
|
2026-01-07 20:51:13 -05:00
|
|
|
# Redis (legacy default for Celery broker)
|
2025-11-21 12:00:00 +00:00
|
|
|
redis_url: str = "redis://localhost:6379/0"
|
|
|
|
|
|
2026-01-07 20:51:13 -05:00
|
|
|
# Task queue
|
|
|
|
|
task_queue_driver: Literal["celery", "inmemory"] = "celery"
|
|
|
|
|
task_queue_broker_url: str | None = None
|
|
|
|
|
task_queue_backend: Literal["redis", "sqs"] = "redis"
|
|
|
|
|
task_queue_default_queue: str = "default"
|
|
|
|
|
task_queue_critical_queue: str = "critical"
|
|
|
|
|
task_queue_visibility_timeout: int = 600
|
|
|
|
|
task_queue_polling_interval: float = 1.0
|
|
|
|
|
notification_escalation_delay_seconds: int = 900
|
|
|
|
|
|
|
|
|
|
# AWS (used when task_queue_backend="sqs")
|
|
|
|
|
aws_region: str | None = None
|
|
|
|
|
|
2025-11-21 12:00:00 +00:00
|
|
|
# JWT
|
|
|
|
|
jwt_secret_key: str
|
|
|
|
|
jwt_algorithm: str = "HS256"
|
|
|
|
|
jwt_issuer: str = "incidentops"
|
|
|
|
|
jwt_audience: str = "incidentops-api"
|
|
|
|
|
access_token_expire_minutes: int = 15
|
|
|
|
|
refresh_token_expire_days: int = 30
|
|
|
|
|
|
|
|
|
|
# Application
|
|
|
|
|
debug: bool = False
|
|
|
|
|
api_v1_prefix: str = "/v1"
|
|
|
|
|
|
2026-01-07 20:51:13 -05:00
|
|
|
# OpenTelemetry
|
|
|
|
|
otel_enabled: bool = True
|
|
|
|
|
otel_service_name: str = "incidentops-api"
|
|
|
|
|
otel_environment: str = "development"
|
|
|
|
|
otel_exporter_otlp_endpoint: str | None = None # e.g., "http://tempo:4317"
|
|
|
|
|
otel_exporter_otlp_insecure: bool = True
|
|
|
|
|
otel_log_level: str = "INFO"
|
|
|
|
|
|
|
|
|
|
# Metrics
|
|
|
|
|
prometheus_port: int = 9464 # Port for Prometheus metrics endpoint
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def resolved_task_queue_broker_url(self) -> str:
|
|
|
|
|
"""Return the broker URL with redis fallback for backwards compatibility."""
|
|
|
|
|
|
|
|
|
|
return self.task_queue_broker_url or self.redis_url
|
|
|
|
|
|
2025-11-21 12:00:00 +00:00
|
|
|
|
2026-01-07 20:51:13 -05:00
|
|
|
settings = Settings() # type: ignore[call-arg]
|