From 70a148dd86be9c8ccc56e1fce232262475aa3158 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Sat, 16 Aug 2025 14:13:14 +0200 Subject: feat(aggregator): write evaluation --- crates/aggregator/src/state.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 crates/aggregator/src/state.rs (limited to 'crates/aggregator/src/state.rs') diff --git a/crates/aggregator/src/state.rs b/crates/aggregator/src/state.rs new file mode 100644 index 0000000..ac4f574 --- /dev/null +++ b/crates/aggregator/src/state.rs @@ -0,0 +1,42 @@ +use sqlx::PgPool; +use std::{ops::Deref, sync::Arc}; + +use async_nats::jetstream::Context; +use warden_stack::{Configuration, cache::RedisManager}; + +use crate::cnfg::LocalConfig; + +#[derive(Clone)] +pub struct Services { + pub jetstream: Context, + pub cache: RedisManager, + pub postgres: PgPool, +} + +#[derive(Clone)] +pub struct AppState { + pub services: Services, + pub config: LocalConfig, +} + +#[derive(Clone)] +pub struct AppHandle(pub Arc); + +impl Deref for AppHandle { + type Target = Arc; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl AppState { + pub async fn create( + services: Services, + configuration: &Configuration, + ) -> anyhow::Result { + let config = serde_json::from_value(configuration.misc.clone())?; + + Ok(AppHandle(Arc::new(Self { services, config }))) + } +} -- cgit v1.2.3