feat: 更新代码中的日志信息和注释为中文,增强可读性,修改适配器注册流程
This commit is contained in:
@@ -12,7 +12,7 @@ from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from mofox_bus import AdapterBase as MoFoxAdapterBase, CoreSink, MessageEnvelope
|
||||
from mofox_bus import AdapterBase as MoFoxAdapterBase, CoreSink, MessageEnvelope, ProcessCoreSink
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.plugin_system.base.base_plugin import BasePlugin
|
||||
@@ -62,6 +62,28 @@ class BaseAdapter(MoFoxAdapterBase, ABC):
|
||||
self._config: Dict[str, Any] = {}
|
||||
self._health_check_task: Optional[asyncio.Task] = None
|
||||
self._running = False
|
||||
# 标记是否在子进程中运行(由核心管理器传入 ProcessCoreSink 时自动生效)
|
||||
self._is_subprocess = isinstance(core_sink, ProcessCoreSink)
|
||||
|
||||
@classmethod
|
||||
def from_process_queues(
|
||||
cls,
|
||||
to_core_queue,
|
||||
from_core_queue,
|
||||
plugin: Optional["BasePlugin"] = None,
|
||||
**kwargs: Any,
|
||||
) -> "BaseAdapter":
|
||||
"""
|
||||
子进程入口便捷构造:使用 multiprocessing.Queue 与核心建立 ProcessCoreSink 通讯。
|
||||
|
||||
Args:
|
||||
to_core_queue: 发往核心的 multiprocessing.Queue
|
||||
from_core_queue: 核心回传的 multiprocessing.Queue
|
||||
plugin: 可选插件实例
|
||||
**kwargs: 透传给适配器构造函数
|
||||
"""
|
||||
sink = ProcessCoreSink(to_core_queue=to_core_queue, from_core_queue=from_core_queue)
|
||||
return cls(core_sink=sink, plugin=plugin, **kwargs)
|
||||
|
||||
@property
|
||||
def config(self) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user