From 0ca42236d651d4496f38424b795f55dfe42d4389 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:19:51 +0800 Subject: [PATCH] feat(event): add ModuleReload event type --- app/core/module.py | 3 +++ app/schemas/types.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/core/module.py b/app/core/module.py index ce7a7c4fa..e16a6b33d 100644 --- a/app/core/module.py +++ b/app/core/module.py @@ -2,8 +2,10 @@ from typing import Generator, Optional, Tuple, Any 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.utils.object import ObjectUtils from app.utils.singleton import Singleton @@ -67,6 +69,7 @@ def reload(self): """ self.stop() self.load_modules() + eventmanager.send_event(etype=EventType.ModuleReload, data={}) def test(self, modleid: str) -> Tuple[bool, str]: """ diff --git a/app/schemas/types.py b/app/schemas/types.py index da8913781..ebea3ad5b 100644 --- a/app/schemas/types.py +++ b/app/schemas/types.py @@ -56,6 +56,8 @@ class EventType(Enum): SystemError = "system.error" # 刮削元数据 MetadataScrape = "metadata.scrape" + # 模块需要重载 + ModuleReload = "module.reload" # 同步链式事件