新增了插件相关的完整领域模型、应用服务、基础设施实现,包括: 1. 插件状态、注册模式、来源等基础枚举和数据结构 2. 插件清单解析、发现、加载工具类 3. 插件注册表领域服务和内存存储实现 4. 插件相关的命令、查询、事件定义 5. 插件REST API接口和DTO映射 6. 集成了原有通道适配器到插件系统 7. 新增内置插件注册和自动发现能力
93 lines
3.0 KiB
Python
93 lines
3.0 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
class PluginException(Exception):
|
|
def __init__(self, message: str = "", plugin_id: str = ""):
|
|
self.plugin_id = plugin_id
|
|
super().__init__(message)
|
|
|
|
|
|
class DuplicatePluginException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin already exists: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginNotFoundException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin not found: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginAlreadyRegisteredException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin already registered: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginAlreadyActivatedException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin already activated: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginNotConfiguredException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin not configured: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginAdapterNotFoundException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"adapter class not found for plugin: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginRegistrationException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin registration failed: {plugin_id}", plugin_id)
|
|
|
|
|
|
class PluginReloadException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"plugin reload failed: {plugin_id}", plugin_id)
|
|
|
|
|
|
class InvalidManifestException(PluginException):
|
|
def __init__(self, message: str):
|
|
super().__init__(f"invalid manifest: {message}")
|
|
|
|
|
|
class RegistryLockedException(PluginException):
|
|
def __init__(self):
|
|
super().__init__("registry is locked")
|
|
|
|
|
|
class SnapshotException(PluginException):
|
|
def __init__(self, message: str = "snapshot operation failed"):
|
|
super().__init__(message)
|
|
|
|
|
|
class ConfigValidationException(PluginException):
|
|
def __init__(self, plugin_id: str, message: str):
|
|
super().__init__(f"config validation failed for {plugin_id}: {message}", plugin_id)
|
|
|
|
|
|
class ConfigNotFoundException(PluginException):
|
|
def __init__(self, plugin_id: str):
|
|
super().__init__(f"config not found for plugin: {plugin_id}", plugin_id)
|
|
|
|
|
|
class InvalidPluginStateException(PluginException):
|
|
def __init__(self, plugin_id: str, current_status: str, target_action: str):
|
|
super().__init__(
|
|
f"cannot {target_action} plugin {plugin_id} in {current_status} state",
|
|
plugin_id,
|
|
)
|
|
self.current_status = current_status
|
|
self.target_action = target_action
|
|
|
|
|
|
class ActiveSessionExistsException(PluginException):
|
|
def __init__(self, plugin_id: str, channel_type: str, active_count: int):
|
|
super().__init__(
|
|
f"channel {channel_type} has {active_count} active sessions, graceful deactivate required",
|
|
plugin_id,
|
|
)
|
|
self.channel_type = channel_type
|
|
self.active_count = active_count
|