diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-15 08:47:26 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-15 08:50:25 +0200 |
commit | d9a6a849687f508c1d2b9e87f40e69ea7e085bb7 (patch) | |
tree | 02d9d1d6d5ce356dea3e93d363e90b4958ba2244 | |
parent | 43ec1a6e3618db0c35970b6eddb87a4e83c8b622 (diff) |
Handle lifecycle errors at plugin main()
This patch adds lifecycle-error handling during Plugin main() calling.
One might argue that we should shutdown the other plugins that
successfully started. This is not implemented in this patch.
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | crates/core/tedge_core/src/reactor.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/core/tedge_core/src/reactor.rs b/crates/core/tedge_core/src/reactor.rs index 3c4e6a91..21252537 100644 --- a/crates/core/tedge_core/src/reactor.rs +++ b/crates/core/tedge_core/src/reactor.rs @@ -218,7 +218,7 @@ impl Reactor { .await; debug!("Running 'main' for plugins"); - let _main_results = all_plugins + let (_main_results_ok, main_results_err): (Vec<_>, Vec<_>) = all_plugins .iter_mut() .map(|plugin_task| { let span = @@ -228,7 +228,15 @@ impl Reactor { .collect::<futures::stream::FuturesUnordered<_>>() .collect::<Vec<Result<(), _>>>() .instrument(tracing::info_span!("core.mainloop.plugins.main")) - .await; + .await + .into_iter() + .partition_result(); + + if !main_results_err.is_empty() { + return Err(TedgeApplicationError::PluginLifecycleErrors { + errors: main_results_err, + }); + } // And now we wait until all communication is finished. // |