Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
app_name: str = "Payment Processing Service"
|
||||
api_key: str = Field(default="change-me", min_length=1)
|
||||
database_url: str = "postgresql+asyncpg://payments:payments@localhost:5432/payments"
|
||||
rabbitmq_url: str = "amqp://guest:guest@localhost:5672/"
|
||||
outbox_poll_interval: float = Field(default=1.0, gt=0)
|
||||
outbox_batch_size: int = Field(default=100, gt=0)
|
||||
outbox_publish_timeout: float = Field(default=10.0, gt=0)
|
||||
processing_min_seconds: float = Field(default=2.0, ge=0)
|
||||
processing_max_seconds: float = Field(default=5.0, ge=0)
|
||||
processing_success_rate: float = Field(default=0.9, ge=0, le=1)
|
||||
processing_max_attempts: int = Field(default=3, ge=1)
|
||||
retry_base_delay: float = Field(default=1.0, ge=0)
|
||||
webhook_timeout: float = Field(default=10.0, gt=0)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
|
||||
|
||||
settings = get_settings()
|
||||
Reference in New Issue
Block a user