mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor: 收口 V3 分层架构与插件兼容边界
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""插件运行时目录的应用层端口。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Protocol
|
||||
|
||||
|
||||
class PluginRuntime(Protocol):
|
||||
"""声明入口层消费的插件宿主能力。"""
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
"""允许兼容门面按既有 V3 方法名访问插件宿主能力。"""
|
||||
|
||||
|
||||
PluginRuntimeProvider = Callable[[], PluginRuntime]
|
||||
|
||||
|
||||
def _unconfigured_runtime() -> PluginRuntime:
|
||||
"""拒绝在启动组合根完成前隐式创建 Runtime 管理器。"""
|
||||
raise RuntimeError("插件运行时尚未由启动组合根装配")
|
||||
|
||||
|
||||
_runtime_provider: PluginRuntimeProvider = _unconfigured_runtime
|
||||
|
||||
|
||||
def configure_plugin_runtime(provider: PluginRuntimeProvider) -> None:
|
||||
"""由启动组合根注册插件运行时实例提供器。"""
|
||||
global _runtime_provider
|
||||
_runtime_provider = provider
|
||||
|
||||
|
||||
def get_plugin_manager() -> PluginRuntime:
|
||||
"""返回当前组合根提供的插件运行时能力。"""
|
||||
return _runtime_provider()
|
||||
Reference in New Issue
Block a user