50 lines
2.0 KiB
Python
50 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Settings:
|
|
app_name: str = "TradingView Alert Dispatcher"
|
|
host: str = "0.0.0.0"
|
|
port: int = 8000
|
|
database_path: str = "data/dispatcher.db"
|
|
admin_username: str = "admin"
|
|
admin_password: str = "change-me-now"
|
|
session_secret: str = "change-this-session-secret"
|
|
webhook_token: str = ""
|
|
retention_days: int = 30
|
|
max_delivery_attempts: int = 3
|
|
retry_backoff_seconds: int = 60
|
|
feishu_timeout_seconds: int = 10
|
|
timezone: str = ""
|
|
dispatch_inline: bool = False
|
|
dispatch_wakeup_on_receive: bool = True
|
|
delivery_batch_size: int = 100
|
|
delivery_concurrency: int = 5
|
|
worker_interval_seconds: int = 2
|
|
|
|
|
|
def get_settings() -> Settings:
|
|
return Settings(
|
|
host=os.getenv("APP_HOST", "0.0.0.0"),
|
|
port=int(os.getenv("APP_PORT", "8000")),
|
|
database_path=os.getenv("DATABASE_PATH", "data/dispatcher.db"),
|
|
admin_username=os.getenv("ADMIN_USERNAME", "admin"),
|
|
admin_password=os.getenv("ADMIN_PASSWORD", "change-me-now"),
|
|
session_secret=os.getenv("SESSION_SECRET", "change-this-session-secret"),
|
|
webhook_token=os.getenv("WEBHOOK_TOKEN", ""),
|
|
retention_days=int(os.getenv("RETENTION_DAYS", "30")),
|
|
max_delivery_attempts=int(os.getenv("MAX_DELIVERY_ATTEMPTS", "3")),
|
|
retry_backoff_seconds=int(os.getenv("RETRY_BACKOFF_SECONDS", "60")),
|
|
feishu_timeout_seconds=int(os.getenv("FEISHU_TIMEOUT_SECONDS", "10")),
|
|
timezone=os.getenv("APP_TIMEZONE") or os.getenv("TZ", ""),
|
|
dispatch_inline=os.getenv("DISPATCH_INLINE", "").lower() in {"1", "true", "yes", "on"},
|
|
dispatch_wakeup_on_receive=os.getenv("DISPATCH_WAKEUP_ON_RECEIVE", "true").lower()
|
|
in {"1", "true", "yes", "on"},
|
|
delivery_batch_size=int(os.getenv("DELIVERY_BATCH_SIZE", "100")),
|
|
delivery_concurrency=int(os.getenv("DELIVERY_CONCURRENCY", "5")),
|
|
worker_interval_seconds=int(os.getenv("WORKER_INTERVAL_SECONDS", "2")),
|
|
)
|