diff options
| author | rtkay123 <dev@kanjala.com> | 2026-03-29 16:36:13 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-03-29 16:36:13 +0200 |
| commit | ff3b9fbaf400c344cae67ef9bdc9ba7d5f27b976 (patch) | |
| tree | ce417252c6ea56c540e4c78f43c9ad4af9b76c64 /lib/warden-core/src/state/mod.rs | |
| parent | 57c4a5251c30d3dc2b78059fd208d8948d999056 (diff) | |
| download | warden-ff3b9fbaf400c344cae67ef9bdc9ba7d5f27b976.tar.bz2 warden-ff3b9fbaf400c344cae67ef9bdc9ba7d5f27b976.zip | |
refactor: move state to core
Diffstat (limited to 'lib/warden-core/src/state/mod.rs')
| -rw-r--r-- | lib/warden-core/src/state/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/warden-core/src/state/mod.rs b/lib/warden-core/src/state/mod.rs new file mode 100644 index 0000000..f4692c2 --- /dev/null +++ b/lib/warden-core/src/state/mod.rs @@ -0,0 +1,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, + }) + } +} |
