Skip to main content

CommunicationService

Trait CommunicationService 

Source
pub trait CommunicationService: Sync + Send {
    // Required methods
    fn install(
        &mut self,
        api_receiver: InternalAPIReceiver,
        event_sender: InternalEventSender,
    );
    fn uninstall(&mut self);
    fn stop(&self);
    fn start<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn restart<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

fn install( &mut self, api_receiver: InternalAPIReceiver, event_sender: InternalEventSender, )

安装服务
该方法仅进行服务的依赖注入,并不真正创建任务
应具备幂等性

Source

fn uninstall(&mut self)

卸载服务
服务应回收安装后产生的一切副作用和安装时注入的依赖
应具备幂等性

Source

fn stop(&self)

停止服务
不同于 uninstall 方法 ,stop 方法仅需要回收安装后产生的副作用,并不需要回收安装时注入的依赖
应具备幂等性

Source

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

开始服务
服务内应保证任务在服务的生命周期内最多存在一个
由于在服务生命周期内最多存在一个任务,所以该方法 应具备幂等性

Provided Methods§

Source

fn restart<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

重启服务
不具备幂等性

Trait Implementations§

Source§

impl CommunicationService for Box<dyn CommunicationService>

Source§

fn install( &mut self, api_receiver: InternalAPIReceiver, event_sender: InternalEventSender, )

安装服务
该方法仅进行服务的依赖注入,并不真正创建任务
应具备幂等性
Source§

fn uninstall(&mut self)

卸载服务
服务应回收安装后产生的一切副作用和安装时注入的依赖
应具备幂等性
Source§

fn stop(&self)

停止服务
不同于 uninstall 方法 ,stop 方法仅需要回收安装后产生的副作用,并不需要回收安装时注入的依赖
应具备幂等性
Source§

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

开始服务
服务内应保证任务在服务的生命周期内最多存在一个
由于在服务生命周期内最多存在一个任务,所以该方法 应具备幂等性
Source§

fn restart<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

重启服务
不具备幂等性

Implementations on Foreign Types§

Source§

impl CommunicationService for Box<dyn CommunicationService>

Source§

fn install( &mut self, api_receiver: InternalAPIReceiver, event_sender: InternalEventSender, )

Source§

fn uninstall(&mut self)

Source§

fn stop(&self)

Source§

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn restart<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ServiceStartResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§