mirror of
https://github.com/perstarkse/minne.git
synced 2026-06-30 01:51:43 +02:00
7c718712c9
- ingestion_pipeline::run_worker_loop returns anyhow::Result<()> - api_router::ApiState::new returns anyhow::Result<Self> - html_router::HtmlState::new_with_resources is infallible, returns Self - main/server/worker binary entry points return anyhow::Result<()>
42 lines
965 B
Rust
42 lines
965 B
Rust
use std::sync::Arc;
|
|
|
|
use common::{
|
|
storage::{db::SurrealDbClient, store::StorageManager},
|
|
utils::config::AppConfig,
|
|
};
|
|
|
|
#[derive(Clone)]
|
|
pub struct ApiState {
|
|
pub db: Arc<SurrealDbClient>,
|
|
pub config: AppConfig,
|
|
pub storage: StorageManager,
|
|
}
|
|
|
|
impl ApiState {
|
|
pub async fn new(
|
|
config: &AppConfig,
|
|
storage: StorageManager,
|
|
) -> anyhow::Result<Self> {
|
|
let surreal_db_client = Arc::new(
|
|
SurrealDbClient::new(
|
|
&config.surrealdb_address,
|
|
&config.surrealdb_username,
|
|
&config.surrealdb_password,
|
|
&config.surrealdb_namespace,
|
|
&config.surrealdb_database,
|
|
)
|
|
.await?,
|
|
);
|
|
|
|
surreal_db_client.apply_migrations().await?;
|
|
|
|
let app_state = Self {
|
|
db: surreal_db_client.clone(),
|
|
config: config.clone(),
|
|
storage,
|
|
};
|
|
|
|
Ok(app_state)
|
|
}
|
|
}
|