Files
NebulaShell/store/@{FutureOSS}/plugin-loader-pro/main.py
qwen.ai[bot] 97ced1b5e6 Title: Implement minimal core framework with PL injection and update build config
Key features implemented:
- Updated package metadata and dependencies in PKG-INFO, setup files
- Added main.py entry point for backward compatibility with README launch method
- Enhanced CLI with config options, system info command, and proper signal handling
- Implemented minimal PluginManager loading only plugin-loader core plugin
- Refactored PluginLoader to follow minimal core design, removed sandbox/isolation complexity
- Updated auto-dependency plugin with safer PL injection mechanism and disabled pl_injection
- Removed legacy plugin files (firewall, frp_proxy, ftp_server, multi_lang_deploy, ops_toolbox, security_gateway) as functionality moved to core plugin system
- Improved gitignore with comprehensive ignore patterns

The changes implement a minimal core framework design where only the plugin-loader is directly loaded by the core, with all other plugins managed through the PL injection mechanism, significantly simplifying the architecture.
2026-04-25 10:47:26 +00:00

77 lines
2.1 KiB
Python

"""插件加载 Pro - 为 plugin-loader 提供高级机制"""
from oss.plugin.types import Plugin, register_plugin_type
from .core.config import ProConfig
from .core.enhancer import PluginLoaderEnhancer
from .utils.logger import ProLogger
class PluginLoaderPro(Plugin):
"""插件加载 Pro - 增强器"""
def __init__(self):
self.plugin_loader = None
self.enhancer = None
self.config = None
self._started = False
def meta(self):
from oss.plugin.types import Metadata, PluginConfig, Manifest
return Manifest(
metadata=Metadata(
name="plugin-loader-pro",
version="1.0.0",
author="FutureOSS",
description="为 plugin-loader 提供熔断、降级、容错、自动修复等高级机制"
),
config=PluginConfig(
enabled=True,
args={}
),
dependencies=["plugin-loader"]
)
def set_plugin_loader(self, plugin_loader):
self.plugin_loader = plugin_loader
ProLogger.info("main", "已注入 plugin-loader")
def init(self, deps: dict = None):
if not self.plugin_loader:
ProLogger.warn("main", "未找到 plugin-loader 依赖")
return
config = {}
if deps:
config = deps.get("config", {})
self.config = ProConfig(config)
self.enhancer = PluginLoaderEnhancer(
self.plugin_loader.manager,
self.config
)
ProLogger.info("main", "增强器已初始化")
def start(self):
if self._started:
return
self._started = True
if not self.enhancer:
ProLogger.warn("main", "增强器未初始化,跳过启动")
return
ProLogger.info("main", "开始增强 plugin-loader...")
self.enhancer.enhance()
def stop(self):
ProLogger.info("main", "停止增强器...")
if self.enhancer:
self.enhancer.disable()
register_plugin_type("PluginLoaderPro", PluginLoaderPro)
def New():
return PluginLoaderPro()