mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 15:09:46 +08:00
refactor: make subscription lifecycle events durable
This commit is contained in:
@@ -17,7 +17,7 @@ from app.api.data import (
|
||||
get_api_data_ports,
|
||||
)
|
||||
from app.startup import lifecycle
|
||||
from app.startup.context import AgentChatRuntime, HostRuntime
|
||||
from app.startup.context import AgentChatRuntime, HostRuntime, SubscriptionRuntime
|
||||
|
||||
|
||||
class _Repository:
|
||||
@@ -42,6 +42,20 @@ class _UnitOfWork:
|
||||
"""模拟回滚。"""
|
||||
|
||||
|
||||
class _Outbox:
|
||||
"""记录绑定会话的异步 outbox 替身。"""
|
||||
|
||||
def __init__(self, session: object) -> None:
|
||||
"""保存与订阅仓储相同的请求会话。"""
|
||||
self.session = session
|
||||
|
||||
async def stage(self, intent, now) -> None:
|
||||
"""模拟暂存 durable intent。"""
|
||||
|
||||
async def complete_by_event_key(self, event_key, completed_at) -> None:
|
||||
"""模拟收口 durable intent。"""
|
||||
|
||||
|
||||
def _runtime() -> HostRuntime:
|
||||
"""构造不加载数据库引擎或 PluginManager 的假宿主运行时。"""
|
||||
async def async_session():
|
||||
@@ -66,6 +80,13 @@ def _runtime() -> HostRuntime:
|
||||
repository=_Repository,
|
||||
transaction=_UnitOfWork,
|
||||
),
|
||||
subscription=SubscriptionRuntime(
|
||||
async_session=async_session,
|
||||
repository=_Repository,
|
||||
history_repository=_Repository,
|
||||
transaction=_UnitOfWork,
|
||||
outbox=_Outbox,
|
||||
),
|
||||
compatibility_api_data=compatibility,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user