add ModuleType Schema

This commit is contained in:
jxxghp
2024-10-12 11:50:00 +08:00
parent fcfeeb09d3
commit 603ab97665
27 changed files with 248 additions and 148 deletions
+12 -1
View File
@@ -5,7 +5,7 @@ from app.core.config import settings
from app.core.event import eventmanager
from app.helper.module import ModuleHelper
from app.log import logger
from app.schemas.types import EventType
from app.schemas.types import EventType, ModuleType
from app.utils.object import ObjectUtils
from app.utils.singleton import Singleton
@@ -124,6 +124,17 @@ class ModuleManager(metaclass=Singleton):
and ObjectUtils.check_method(getattr(module, method)):
yield module
def get_running_type_modules(self, module_type: ModuleType) -> Generator:
"""
获取指定类型的模块列表
"""
if not self._running_modules:
return []
for _, module in self._running_modules.items():
if hasattr(module, 'get_type') \
and module.get_type() == module_type:
yield module
def get_module(self, module_id: str) -> Any:
"""
根据模块id获取模块