Add analyze channel to AppState
Introduces a new channel for the analyze pipeline, including its sender in the `AppState`. Also updates the test router to create both transcribe and analyze channels.
This commit is contained in:
+22
-5
@@ -8,6 +8,7 @@ use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
use doctate_server::analyze;
|
||||
use doctate_server::config::Config;
|
||||
use doctate_server::transcribe;
|
||||
use doctate_server::AppState;
|
||||
@@ -39,18 +40,18 @@ async fn main() {
|
||||
)
|
||||
.init();
|
||||
|
||||
// Transcription pipeline: shared HTTP client + worker task.
|
||||
let (transcribe_tx, transcribe_rx) = transcribe::channel();
|
||||
// Shared HTTP client for both downstream pipelines.
|
||||
let http_client = reqwest::Client::builder()
|
||||
.build()
|
||||
.expect("reqwest client build failed");
|
||||
|
||||
// Transcription pipeline: channel + worker + recovery scan.
|
||||
let (transcribe_tx, transcribe_rx) = transcribe::channel();
|
||||
tokio::spawn(transcribe::worker::run(
|
||||
transcribe_rx,
|
||||
config.clone(),
|
||||
http_client,
|
||||
http_client.clone(),
|
||||
));
|
||||
|
||||
// Re-enqueue pending recordings left over from a previous run.
|
||||
{
|
||||
let tx = transcribe_tx.clone();
|
||||
let data_path = config.data_path.clone();
|
||||
@@ -59,9 +60,25 @@ async fn main() {
|
||||
});
|
||||
}
|
||||
|
||||
// Analyze pipeline: channel + worker + recovery scan.
|
||||
let (analyze_tx, analyze_rx) = analyze::channel();
|
||||
tokio::spawn(analyze::worker::run(
|
||||
analyze_rx,
|
||||
config.clone(),
|
||||
http_client.clone(),
|
||||
));
|
||||
{
|
||||
let tx = analyze_tx.clone();
|
||||
let data_path = config.data_path.clone();
|
||||
tokio::spawn(async move {
|
||||
analyze::recovery::scan_and_enqueue(&data_path, &tx).await;
|
||||
});
|
||||
}
|
||||
|
||||
let state = AppState {
|
||||
config: config.clone(),
|
||||
transcribe_tx,
|
||||
analyze_tx,
|
||||
session_store: doctate_server::web_session::new_store(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user