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:
+15
-5
@@ -12,6 +12,7 @@ use std::sync::Arc;
|
||||
use axum::extract::FromRef;
|
||||
use axum::Router;
|
||||
|
||||
use analyze::AnalyzeSender;
|
||||
use config::Config;
|
||||
use transcribe::TranscribeSender;
|
||||
use web_session::SessionStore;
|
||||
@@ -22,6 +23,7 @@ use web_session::SessionStore;
|
||||
pub struct AppState {
|
||||
pub config: Arc<Config>,
|
||||
pub transcribe_tx: TranscribeSender,
|
||||
pub analyze_tx: AnalyzeSender,
|
||||
pub session_store: SessionStore,
|
||||
}
|
||||
|
||||
@@ -37,20 +39,28 @@ impl FromRef<AppState> for TranscribeSender {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromRef<AppState> for AnalyzeSender {
|
||||
fn from_ref(state: &AppState) -> Self {
|
||||
state.analyze_tx.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromRef<AppState> for SessionStore {
|
||||
fn from_ref(state: &AppState) -> Self {
|
||||
state.session_store.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Test/simple entrypoint: jobs pushed into the transcribe channel are dropped
|
||||
/// because the receiver is not retained. Use [`create_router_with_state`] from
|
||||
/// `main.rs` where a real worker owns the receiver.
|
||||
/// Test/simple entrypoint: jobs pushed into either channel are dropped
|
||||
/// because the receivers are not retained. Use [`create_router_with_state`]
|
||||
/// from `main.rs` where real workers own the receivers.
|
||||
pub fn create_router(config: Arc<Config>) -> Router {
|
||||
let (tx, _rx) = transcribe::channel();
|
||||
let (transcribe_tx, _transcribe_rx) = transcribe::channel();
|
||||
let (analyze_tx, _analyze_rx) = analyze::channel();
|
||||
create_router_with_state(AppState {
|
||||
config,
|
||||
transcribe_tx: tx,
|
||||
transcribe_tx,
|
||||
analyze_tx,
|
||||
session_store: web_session::new_store(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user