diff options
| author | soryu <soryu@soryu.co> | 2025-12-23 02:14:58 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2025-12-23 14:47:18 +0000 |
| commit | a32dc56d2e5447ef8988cb98b8686476cc94e70c (patch) | |
| tree | 61307503c4af82103cea2360fe95d3ea324968d6 /makima/src/server/state.rs | |
| parent | 73649d135efccda7e446775db773e21b458de202 (diff) | |
| download | soryu-a32dc56d2e5447ef8988cb98b8686476cc94e70c.tar.gz soryu-a32dc56d2e5447ef8988cb98b8686476cc94e70c.zip | |
Add Postgres for persistence and File cabinet
Migrations are local only currently, and must be run manually by setting POSTGRES_CONNECTION_URI
Diffstat (limited to 'makima/src/server/state.rs')
| -rw-r--r-- | makima/src/server/state.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs index 31e1518..8cdc26c 100644 --- a/makima/src/server/state.rs +++ b/makima/src/server/state.rs @@ -1,11 +1,12 @@ -//! Application state holding shared ML models. +//! Application state holding shared ML models and database pool. use std::sync::Arc; +use sqlx::PgPool; use tokio::sync::Mutex; use crate::listen::{DiarizationConfig, ParakeetEOU, ParakeetTDT, Sortformer}; -/// Shared application state containing ML models. +/// Shared application state containing ML models and database pool. /// /// Models are wrapped in `Mutex` for thread-safe mutable access during inference. pub struct AppState { @@ -15,6 +16,8 @@ pub struct AppState { pub parakeet_eou: Mutex<ParakeetEOU>, /// Speaker diarization model (Sortformer) pub sortformer: Mutex<Sortformer>, + /// Optional database connection pool + pub db_pool: Option<PgPool>, } impl AppState { @@ -41,8 +44,15 @@ impl AppState { parakeet: Mutex::new(parakeet), parakeet_eou: Mutex::new(parakeet_eou), sortformer: Mutex::new(sortformer), + db_pool: None, }) } + + /// Set the database pool. + pub fn with_db_pool(mut self, pool: PgPool) -> Self { + self.db_pool = Some(pool); + self + } } /// Type alias for the shared application state. |
