From 849820e626b06f8e99f2e88b1391d101bca3640c Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 23 Apr 2024 14:00:33 +0100 Subject: Refactor action dispatching to run_actions() --- src/actions.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/actions.rs') diff --git a/src/actions.rs b/src/actions.rs index bf78414..d006207 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -1,6 +1,7 @@ use std::fmt; use anyhow::Result; +use async_scoped::TokioScope; use async_trait::async_trait; use log::{debug, info, warn}; use serde::Deserialize; @@ -119,3 +120,14 @@ pub async fn get_actions<'a>( result } + +pub async fn run_actions( + actions: &[&(dyn Action<'_> + Sync)], + params: Option>, +) { + TokioScope::scope_and_block(|s| { + for &action in actions { + s.spawn(action.run(params.as_ref())); + } + }); +} -- cgit v1.2.3-70-g09d2