Files
RuoYi-Vue3-FastAPI/ruoyi-fastapi-backend/cli/runtime/plugin/gateway.py
T
insistence 2a055ba648 feat: 新增插件系统 (#112)
* feat: 初始化插件系统

* refactor: 收口插件系统运行时重构

* perf: 优化插件系统类型提示

* fix&perf: 修复和优化插件系统

* fix: 修复gitignore规则误忽略插件文件的问题

* fix: 修复运行时插件根路径算错的问题

* fix: 加强插件发现和路由注册的防护措施

* revert: 回滚定时任务白名单

* fix: 移除未使用的应用路由注册探测

* revert: 恢复部分代码

* perf: 优化插件系统

* docs: 新增插件开发文档

* perf: 优化插件管理模块

* perf: 提升插件系统核心能力

* refactor: 重构生命周期 step runner

* fix: 修复lint错误

* test: 清理测试用例

* test: 调整测试目录名称

* fix: 修复前后端目录硬编码的问题

* fix: 修复插件系统安全性缺口

* refactor: 重新设计插件生命周期 Migration 事务与回滚

* perf: 优化插件系统边界问题

* refactor: 重构当前插件系统的依赖体系设计

* perf: 优化代码

* perf: 优化代码

* fix: 修复代码合并问题

* fix: 修复bug

* perf: 优化代码

* perf&fix: 优化代码和修复bug

* docs: 优化文档格式

* feat: 适配Vue2版本

* docs: 更新README文档

* fix: 修复ruff lint错误

* chore: 更新后端依赖文件
2026-07-28 20:35:18 +08:00

71 lines
2.2 KiB
Python

from importlib import import_module
from typing import Any
class PluginRuntimeGateway:
"""
插件 CLI 运行时网关。
该对象负责延迟加载插件核心运行时与管理适配器,避免导入
`cli.runtime.plugin` 时立即加载 `plugins.core`。
"""
@staticmethod
def get_core_runtime_service_class() -> Any:
"""
获取插件核心运行时服务类。
:return: 插件核心运行时服务类
"""
return import_module('plugins.core.runtime.service').PluginRuntimeService
@staticmethod
def get_core_runtime_gateway_overrides_class() -> Any:
"""
获取插件核心运行时窄端口覆盖项类。
:return: 插件核心运行时窄端口覆盖项类
"""
return import_module('plugins.core.runtime.service.dependency_container').PluginRuntimeGatewayOverrides
@staticmethod
def get_management_runtime_gateway() -> Any:
"""
获取插件管理运行时适配器。
:return: 插件管理运行时适配器实例
"""
gateway_class = import_module('plugins.core.management.service.gateway').PluginManagementRuntimeGateway
return gateway_class()
@staticmethod
def get_core_runtime_environment() -> Any:
"""
获取插件核心运行时环境服务。
:return: 插件核心运行时环境服务
"""
return import_module('plugins.core.environment').PLUGIN_RUNTIME_ENVIRONMENT
@staticmethod
def get_core_lifecycle_lock() -> Any:
"""
获取插件核心生命周期分布式锁。
:return: 插件核心生命周期分布式锁
"""
lock_class = import_module('plugins.core.runtime.service.lifecycle_lock').RedisPluginLifecycleLock
return lock_class()
@staticmethod
def build_exception_payload(message: str, exc: Exception) -> dict[str, object]:
"""
构建插件核心异常负载。
:param message: 异常场景提示
:param exc: 异常对象
:return: 异常负载
"""
payload_builder = import_module('plugins.core.runtime.support').PluginRuntimePayloadBuilder
return payload_builder.build_exception_payload(message, exc)