summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-08-13 09:41:53 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-08-30 13:54:48 +0200
commitf2621287047e93a87c65d45b4420aaf2bf2dbc24 (patch)
tree4ee9d868c02b4e07742acb231919da6bc69eb876
parentd018fbb44ef84bcbd9714c3fc1b8c63d03ef6241 (diff)
Add doc for PluginTask interface
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--crates/core/tedge_core/src/plugin_task.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/core/tedge_core/src/plugin_task.rs b/crates/core/tedge_core/src/plugin_task.rs
index 9ef0e1a3..fa1f158f 100644
--- a/crates/core/tedge_core/src/plugin_task.rs
+++ b/crates/core/tedge_core/src/plugin_task.rs
@@ -44,6 +44,7 @@ impl std::fmt::Debug for PluginTask {
}
impl PluginTask {
+ /// Create a new PluginTask instance
pub fn new(
plugin_name: String,
plugin: Arc<RwLock<BuiltPlugin>>,
@@ -69,6 +70,9 @@ impl PluginTask {
self.plugin_name.as_ref()
}
+ /// Run the "start" lifecycle part
+ ///
+ /// This handles the "start" lifecycle lifecycle part of one [`tedge_api::Plugin`] instance.
pub async fn run_start(&mut self) -> Result<(), PluginLifecycleError> {
let plugin_name: &str = &self.plugin_name;
let mut plug_write = self.plugin.write().await;
@@ -113,6 +117,7 @@ impl PluginTask {
Ok(())
}
+ /// Enable communication for this PluginTask instance
pub async fn enable_communications(&self) -> Result<(), PluginLifecycleError> {
trace!(max_concurrency = ?self.max_concurrency, "enabling communications");
self.plugin_msg_communications
@@ -126,10 +131,9 @@ impl PluginTask {
Ok(())
}
- /// Run the PluginTask
+ /// Run the "main" lifecycle part
///
- /// This handles the complete lifecycle of one [`tedge_api::Plugin`] instance. That includes
- /// message passing as well as the crash-safety of that instance.
+ /// This handles the "main" lifecycle lifecycle part of one [`tedge_api::Plugin`] instance.
pub async fn run_main(&self) -> Result<(), PluginLifecycleError> {
let plug_read = self.plugin.read().await;
@@ -173,12 +177,16 @@ impl PluginTask {
Ok(())
}
+ /// Disable communication for this PluginTask instance
pub async fn disable_communications(&self) -> Result<(), PluginLifecycleError> {
self.plugin_msg_communications.reset().await;
Ok(())
}
+ /// Run the "shutdown" lifecycle part
+ ///
+ /// This handles the "shutdown" lifecycle lifecycle part of one [`tedge_api::Plugin`] instance.
pub async fn run_shutdown(&mut self) -> Result<(), PluginLifecycleError> {
let plugin_name: &str = &self.plugin_name;
let shutdown_timeout = self.shutdown_timeout;