Initial commit - production deployment
This commit is contained in:
72
services/sales/app/core/config.py
Normal file
72
services/sales/app/core/config.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# services/sales/app/core/config.py
|
||||
"""
|
||||
Sales Service Configuration
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from pydantic import Field
|
||||
from shared.config.base import BaseServiceSettings
|
||||
|
||||
|
||||
class Settings(BaseServiceSettings):
|
||||
"""Sales service settings extending base configuration"""
|
||||
|
||||
# Override service-specific settings
|
||||
SERVICE_NAME: str = "sales-service"
|
||||
VERSION: str = "1.0.0"
|
||||
APP_NAME: str = "Bakery Sales Service"
|
||||
DESCRIPTION: str = "Sales data management and analytics service"
|
||||
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("SALES_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("SALES_DB_USER", "sales_user")
|
||||
password = os.getenv("SALES_DB_PASSWORD", "sales_pass123")
|
||||
host = os.getenv("SALES_DB_HOST", "localhost")
|
||||
port = os.getenv("SALES_DB_PORT", "5432")
|
||||
name = os.getenv("SALES_DB_NAME", "sales_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Sales-specific Redis database
|
||||
REDIS_DB: int = Field(default=2, env="SALES_REDIS_DB")
|
||||
|
||||
# File upload configuration
|
||||
MAX_UPLOAD_SIZE: int = 10 * 1024 * 1024 # 10MB
|
||||
UPLOAD_PATH: str = Field(default="/tmp/uploads", env="SALES_UPLOAD_PATH")
|
||||
ALLOWED_FILE_EXTENSIONS: List[str] = [".csv", ".xlsx", ".xls"]
|
||||
|
||||
# Pagination
|
||||
DEFAULT_PAGE_SIZE: int = 50
|
||||
MAX_PAGE_SIZE: int = 1000
|
||||
|
||||
# Data validation
|
||||
MIN_QUANTITY: float = 0.01
|
||||
MAX_QUANTITY: float = 10000.0
|
||||
MIN_REVENUE: float = 0.01
|
||||
MAX_REVENUE: float = 100000.0
|
||||
|
||||
# Sales-specific cache TTL (5 minutes)
|
||||
SALES_CACHE_TTL: int = 300
|
||||
PRODUCT_CACHE_TTL: int = 600 # 10 minutes
|
||||
|
||||
# Inter-service communication
|
||||
INVENTORY_SERVICE_URL: str = Field(
|
||||
default="http://inventory-service:8000",
|
||||
env="INVENTORY_SERVICE_URL"
|
||||
)
|
||||
|
||||
|
||||
# Global settings instance
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user