pub trait AsyncServiceModule: Send + Sync {
// Required method
fn name(&self) -> &str;
// Provided methods
fn is_critical(&self) -> bool { ... }
fn priority(&self) -> i32 { ... }
fn dependencies(&self) -> Vec<&str> { ... }
fn init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn before_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn before_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Internal asynchronous service module trait.
This trait defines the interface for internal asynchronous service modules in DMSC. It provides a comprehensive lifecycle management system with multiple phases.
§Usage
use dmsc::core::{AsyncServiceModule, DMSCResult, DMSCServiceContext};
use async_trait::async_trait;
struct MyInternalAsyncModule;
#[async_trait]
impl AsyncServiceModule for MyInternalAsyncModule {
fn name(&self) -> &str {
"my_internal_async_module"
}
async fn start(&mut self, ctx: &mut DMSCServiceContext) -> DMSCResult<()> {
// Start internal async module logic
Ok(())
}
}Required Methods§
Provided Methods§
Sourcefn is_critical(&self) -> bool
fn is_critical(&self) -> bool
Indicates if the internal module is critical to the operation of the system.
Critical modules will cause the entire system to fail if they encounter an error, while non-critical modules can fail independently.
Default: true
Sourcefn priority(&self) -> i32
fn priority(&self) -> i32
Returns the priority of the internal module.
Modules with higher priority are executed first within the same dependency level.
Default: 0
Sourcefn dependencies(&self) -> Vec<&str>
fn dependencies(&self) -> Vec<&str>
Returns the list of module dependencies.
Dependencies are module names that must be initialized and started before this module. The runtime will ensure dependencies are processed in the correct order.
Default: Vec::new()
Sourcefn init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initializes the internal async service module.
This method is called during the initialization phase to set up module resources.
Default: Ok(())
Sourcefn before_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepares the internal module for startup.
This method is called after initialization but before the main start phase.
Default: Ok(())
Sourcefn start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Starts the internal async service module.
This method is called to start the main functionality of the module.
Default: Ok(())
Sourcefn after_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Performs post-startup operations for the internal module.
This method is called after the main start phase but before the module is considered fully started.
Default: Ok(())
Sourcefn before_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepares the internal module for shutdown.
This method is called before the main shutdown phase.
Default: Ok(())
Sourcefn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Shuts down the internal async service module.
This method is called to stop the main functionality of the module.
Default: Ok(())
Sourcefn after_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_shutdown<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut DMSCServiceContext,
) -> Pin<Box<dyn Future<Output = DMSCResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Performs post-shutdown cleanup for the internal module.
This method is called after the main shutdown phase to clean up resources.
Default: Ok(())