blob: f4692c2421fd6dba6f3969d4389a2ff1fbee0441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
pub(crate) mod database;
use sqlx::PgPool;
use tracing_subscriber::EnvFilter;
use crate::{WardenError, config::Configuration};
pub type LogHandle = tracing_subscriber::reload::Handle<EnvFilter, tracing_subscriber::Registry>;
#[derive(Debug, Clone)]
pub struct AppState {
pub log_handle: LogHandle,
pub database: PgPool,
}
impl AppState {
pub async fn new(log_handle: LogHandle, config: &Configuration) -> Result<Self, WardenError> {
let database = database::connect(&config.database).await?;
Ok(Self {
log_handle,
database,
})
}
}
|