aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/actions.rs
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-04-23 14:00:33 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-04-23 16:08:55 +0100
commit849820e626b06f8e99f2e88b1391d101bca3640c (patch)
tree80bba105eb09e1e9e0ff648be6063419fedb3d2e /src/actions.rs
parenta4326613610afbe73a9f1989e64024b43339c2fb (diff)
downloadsentrum-849820e626b06f8e99f2e88b1391d101bca3640c.tar.gz
sentrum-849820e626b06f8e99f2e88b1391d101bca3640c.tar.bz2
sentrum-849820e626b06f8e99f2e88b1391d101bca3640c.zip
Refactor action dispatching to run_actions()
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs12
1 files changed, 12 insertions, 0 deletions
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<MessageParams<'_, '_>>,
+) {
+ TokioScope::scope_and_block(|s| {
+ for &action in actions {
+ s.spawn(action.run(params.as_ref()));
+ }
+ });
+}