29 lines
1014 B
Python
29 lines
1014 B
Python
"""服务容器:集中管理所有服务实例,用于依赖注入"""
|
|
from dataclasses import dataclass
|
|
|
|
from app.core.config import Settings
|
|
from app.services.browser_fallback import BrowserFallback
|
|
from app.services.rakuma_client import RakumaClient
|
|
from app.services.rakuma_session import RakumaSession
|
|
from app.services.rakuten_client import RakutenClient
|
|
from app.services.site_session import SiteSession
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ServiceContainer:
|
|
"""服务容器,持有所有核心服务实例
|
|
|
|
通过 FastAPI 的 app.state.container 在请求间共享,
|
|
各路由通过依赖注入获取容器中的服务。
|
|
|
|
两个站点各自持有独立的会话与客户端:乐天需要 Akamai cookie 预热与双指纹
|
|
通道,ラクマ 不需要,抓取前提不同不便合并。
|
|
"""
|
|
|
|
settings: Settings
|
|
browser_fallback: BrowserFallback
|
|
site_session: SiteSession
|
|
rakuten_client: RakutenClient
|
|
rakuma_session: RakumaSession
|
|
rakuma_client: RakumaClient
|