pub struct ModuleCommunicationManager { /* private fields */ }Expand description
模块间通信管理器
Implementations§
Source§impl ModuleCommunicationManager
impl ModuleCommunicationManager
Sourcepub fn register_module(
&self,
module_id: String,
name: String,
version: String,
) -> Receiver<Message>
pub fn register_module( &self, module_id: String, name: String, version: String, ) -> Receiver<Message>
注册模块
Sourcepub async fn send_message(&self, message: Message)
pub async fn send_message(&self, message: Message)
发送消息
Sourcepub async fn broadcast_event(
&self,
event_type: EventType,
data: Value,
sender: String,
)
pub async fn broadcast_event( &self, event_type: EventType, data: Value, sender: String, )
广播事件
Sourcepub fn register_event_listener(&self, event_type: EventType, module_id: String)
pub fn register_event_listener(&self, event_type: EventType, module_id: String)
注册事件监听器
Sourcepub fn remove_event_listener(&self, event_type: EventType, module_id: &String)
pub fn remove_event_listener(&self, event_type: EventType, module_id: &String)
移除事件监听器
Sourcepub fn update_module_status(&self, module_id: &String, status: ModuleStatus)
pub fn update_module_status(&self, module_id: &String, status: ModuleStatus)
更新模块状态
Sourcepub fn get_module_status(&self, module_id: &String) -> Option<ModuleStatus>
pub fn get_module_status(&self, module_id: &String) -> Option<ModuleStatus>
获取模块状态
Sourcepub fn list_modules(&self) -> Vec<(String, ModuleInfo)>
pub fn list_modules(&self) -> Vec<(String, ModuleInfo)>
列出所有模块
Sourcepub async fn acknowledge_message(&self, message_id: &String)
pub async fn acknowledge_message(&self, message_id: &String)
确认消息
Sourcepub async fn send_message_with_ack(
&self,
message: Message,
) -> Result<Message, String>
pub async fn send_message_with_ack( &self, message: Message, ) -> Result<Message, String>
发送消息并等待确认
Sourcepub async fn start_heartbeat(&self)
pub async fn start_heartbeat(&self)
启动心跳检测
Sourcepub async fn handle_pong(&self, module_id: &String)
pub async fn handle_pong(&self, module_id: &String)
处理心跳响应
Sourcepub fn get_message_status(&self, message_id: &String) -> Option<MessageStatus>
pub fn get_message_status(&self, message_id: &String) -> Option<MessageStatus>
获取消息状态
Sourcepub fn cleanup_expired_messages(&self)
pub fn cleanup_expired_messages(&self)
清理过期消息
Sourcepub async fn send_message_batch(&self, batch: MessageBatch)
pub async fn send_message_batch(&self, batch: MessageBatch)
发送消息批次
Sourcepub fn queue_message(&self, message: Message)
pub fn queue_message(&self, message: Message)
将消息加入批处理队列
Sourcepub async fn process_message_batches(&self)
pub async fn process_message_batches(&self)
处理消息批次
Sourcepub async fn start_batch_processor(&self)
pub async fn start_batch_processor(&self)
启动批处理器
Sourcepub fn cache_message(&self, key: String, value: Value)
pub fn cache_message(&self, key: String, value: Value)
缓存消息
Sourcepub fn get_cached_message(&self, key: &str) -> Option<Value>
pub fn get_cached_message(&self, key: &str) -> Option<Value>
获取缓存的消息
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
清除缓存
Sourcepub fn set_batch_size_threshold(&mut self, threshold: usize)
pub fn set_batch_size_threshold(&mut self, threshold: usize)
设置批处理大小阈值
Sourcepub fn set_batch_interval(&mut self, interval: u64)
pub fn set_batch_interval(&mut self, interval: u64)
设置批处理间隔
Sourcepub fn set_cache_size_limit(&mut self, limit: usize)
pub fn set_cache_size_limit(&mut self, limit: usize)
设置缓存大小限制
Trait Implementations§
Source§impl Clone for ModuleCommunicationManager
impl Clone for ModuleCommunicationManager
Source§fn clone(&self) -> ModuleCommunicationManager
fn clone(&self) -> ModuleCommunicationManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Send for ModuleCommunicationManager
impl Sync for ModuleCommunicationManager
Auto Trait Implementations§
impl Freeze for ModuleCommunicationManager
impl !RefUnwindSafe for ModuleCommunicationManager
impl Unpin for ModuleCommunicationManager
impl UnsafeUnpin for ModuleCommunicationManager
impl UnwindSafe for ModuleCommunicationManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more