ForcePilot/backend/package/yuxi/channel/infrastructure/plugin/api_guard.py
Kris 9e503becd3
Some checks failed
Deploy VitePress site to Pages / build (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
feat(plugin): 实现完整的插件注册管理系统
新增了插件相关的完整领域模型、应用服务、基础设施实现,包括:
1. 插件状态、注册模式、来源等基础枚举和数据结构
2. 插件清单解析、发现、加载工具类
3. 插件注册表领域服务和内存存储实现
4. 插件相关的命令、查询、事件定义
5. 插件REST API接口和DTO映射
6. 集成了原有通道适配器到插件系统
7. 新增内置插件注册和自动发现能力
2026-05-31 16:44:13 +08:00

36 lines
946 B
Python

from __future__ import annotations
import logging
logger = logging.getLogger(__name__)
class PluginRegistrationApi:
def __init__(self, plugin_id: str, config: dict | None = None):
self._plugin_id = plugin_id
self._config = config or {}
self._closed = False
@property
def is_closed(self) -> bool:
return self._closed
def close(self) -> None:
self._closed = True
@property
def config(self) -> dict:
if self._closed:
raise RuntimeError(f"registration API closed for plugin: {self._plugin_id}")
return self._config
class ApiGuard:
def create(
self, plugin_id: str, config: dict | None = None, logger_: logging.Logger | None = None
) -> PluginRegistrationApi:
api = PluginRegistrationApi(plugin_id, config)
if logger_:
logger_.debug("created registration API for plugin: %s", plugin_id)
return api