2025-12-04 09:20:28 -03:00
|
|
|
|
2025-12-04 09:33:31 -03:00
|
|
|
use botlib::http_client::BotServerClient;
|
2025-12-03 18:42:22 -03:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2025-12-21 23:40:44 -03:00
|
|
|
#[derive(Clone, Debug)]
|
2025-12-03 18:42:22 -03:00
|
|
|
pub struct AppState {
|
2025-12-04 09:33:31 -03:00
|
|
|
pub client: Arc<BotServerClient>,
|
2025-12-03 18:42:22 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AppState {
|
2025-12-21 23:40:44 -03:00
|
|
|
#[must_use]
|
2025-12-03 18:42:22 -03:00
|
|
|
pub fn new() -> Self {
|
2025-12-04 09:33:31 -03:00
|
|
|
let url = std::env::var("BOTSERVER_URL").ok();
|
2025-12-03 18:42:22 -03:00
|
|
|
Self {
|
2025-12-04 09:33:31 -03:00
|
|
|
client: Arc::new(BotServerClient::new(url)),
|
2025-12-03 18:42:22 -03:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-04 09:33:31 -03:00
|
|
|
|
|
|
|
|
pub async fn health_check(&self) -> bool {
|
|
|
|
|
self.client.health_check().await
|
|
|
|
|
}
|
2025-12-03 18:42:22 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for AppState {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self::new()
|
|
|
|
|
}
|
|
|
|
|
}
|