ed21ee11d2
CI/CD Pipeline / Check if frontend-only change (push) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (push) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (push) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (push) Has been cancelled
CI/CD Pipeline / PR Build API Image (push) Has been cancelled
CI/CD Pipeline / PR Build Web Image (push) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
45 lines
1.6 KiB
Python
Executable File
45 lines
1.6 KiB
Python
Executable File
"""Worker 服务配置 — 继承 SharedSettings,只追加 Worker 特有字段。
|
||
|
||
通用配置(DB/Redis/Celery/OSS/CosyVoice/Doubao 等)统一在
|
||
packages/config/base.py 的 SharedSettings 中定义,这里不重复。
|
||
"""
|
||
|
||
from pydantic_settings import SettingsConfigDict
|
||
|
||
from packages.config.base import SharedSettings, get_cached_settings
|
||
|
||
|
||
class WorkerSettings(SharedSettings):
|
||
"""Worker 服务专用配置。
|
||
|
||
通用配置继承自 SharedSettings,这里只定义 Worker 独有字段。
|
||
Celery broker/backend 使用继承的 celery_broker_url / celery_result_backend;
|
||
历史上 Worker 使用 broker_url / result_backend 字段名,通过 property 别名兼容。
|
||
"""
|
||
|
||
# ── Worker 特有 ────────────────────────────────────────────────────
|
||
worker_name: str = "xiaoxia-saas-worker"
|
||
worker_concurrency: int = 4
|
||
worker_max_tasks_per_child: int = 1000
|
||
|
||
model_config = SettingsConfigDict(
|
||
env_file=".env",
|
||
env_file_encoding="utf-8",
|
||
case_sensitive=False,
|
||
extra="ignore",
|
||
)
|
||
|
||
# ── 向后兼容:Celery 字段名别名 ──────────────────────────────────
|
||
@property
|
||
def broker_url(self) -> str:
|
||
return self.celery_broker_url
|
||
|
||
@property
|
||
def result_backend(self) -> str:
|
||
return self.celery_result_backend
|
||
|
||
|
||
def get_worker_settings() -> WorkerSettings:
|
||
"""获取 Worker 配置单例(统一入口)。"""
|
||
return get_cached_settings(WorkerSettings)
|