From 9fc7c22ae87b6cf71d2997ab566371c3376d538a Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 12 Aug 2023 02:26:15 +0200 Subject: [PATCH] Dispatch based on bench method --- src/worker/run.rs | 17 ++++++++++++++++- src/worker/run/internal.rs | 14 ++++++++++++++ src/worker/run/repo.rs | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/worker/run/internal.rs create mode 100644 src/worker/run/repo.rs diff --git a/src/worker/run.rs b/src/worker/run.rs index d27191b..a2f71ca 100644 --- a/src/worker/run.rs +++ b/src/worker/run.rs @@ -1,3 +1,6 @@ +mod internal; +mod repo; + use std::{ collections::HashMap, sync::{Arc, Mutex}, @@ -5,6 +8,7 @@ use std::{ use time::OffsetDateTime; use tokio::sync::mpsc; +use tracing::{debug_span, error, Instrument}; use crate::{ id, @@ -89,5 +93,16 @@ pub async fn run( abort_rx: mpsc::UnboundedReceiver<()>, bench_method: BenchMethod, ) { - // TODO Implement + async { + let result = match bench_method { + BenchMethod::Internal => internal::run(run, abort_rx).await, + BenchMethod::Repo { hash } => repo::run(run, hash, abort_rx).await, + }; + match result { + Ok(()) => {} + Err(e) => error!("Error during run:\n{e:?}"), + } + } + .instrument(debug_span!("run")) + .await; } diff --git a/src/worker/run/internal.rs b/src/worker/run/internal.rs new file mode 100644 index 0000000..4a774a5 --- /dev/null +++ b/src/worker/run/internal.rs @@ -0,0 +1,14 @@ +use std::sync::{Arc, Mutex}; + +use tokio::sync::mpsc; + +use crate::somehow; + +use super::Run; + +pub async fn run( + run: Arc>, + abort_rx: mpsc::UnboundedReceiver<()>, +) -> somehow::Result<()> { + todo!() +} diff --git a/src/worker/run/repo.rs b/src/worker/run/repo.rs new file mode 100644 index 0000000..605b022 --- /dev/null +++ b/src/worker/run/repo.rs @@ -0,0 +1,15 @@ +use std::sync::{Arc, Mutex}; + +use tokio::sync::mpsc; + +use crate::somehow; + +use super::Run; + +pub async fn run( + run: Arc>, + hash: String, + abort_rx: mpsc::UnboundedReceiver<()>, +) -> somehow::Result<()> { + todo!() +}