Add new infra architecture 13
This commit is contained in:
@@ -100,9 +100,33 @@ class BaseServiceSettings(BaseSettings):
|
||||
# DATABASE CONFIGURATION
|
||||
# ================================================================
|
||||
|
||||
# Note: DATABASE_URL is defined as a property in each service-specific config
|
||||
# to construct the URL from secure environment variables
|
||||
|
||||
# DATABASE_URL as a property - can be overridden by service-specific configs
|
||||
# Base implementation reads from environment variable or builds from components
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from environment or components.
|
||||
|
||||
Service-specific configs should override this property to use their
|
||||
own service-specific environment variables (e.g., TENANT_DATABASE_URL).
|
||||
"""
|
||||
# Try complete URL first
|
||||
complete_url = os.getenv("DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Try to build from standard components
|
||||
user = os.getenv("DB_USER", "")
|
||||
password = os.getenv("DB_PASSWORD", "")
|
||||
host = os.getenv("DB_HOST", "localhost")
|
||||
port = os.getenv("DB_PORT", "5432")
|
||||
name = os.getenv("DB_NAME", "")
|
||||
|
||||
if user and password and name:
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Return empty string if not configured (will fail validation in production)
|
||||
return ""
|
||||
|
||||
# Database connection settings
|
||||
DB_POOL_SIZE: int = int(os.getenv("DB_POOL_SIZE", "10"))
|
||||
DB_MAX_OVERFLOW: int = int(os.getenv("DB_MAX_OVERFLOW", "20"))
|
||||
|
||||
Reference in New Issue
Block a user