2025-10-11 12:29:03 -03:00
|
|
|
use crate::bot::BotOrchestrator;
|
|
|
|
|
use crate::channels::{VoiceAdapter, WebChannelAdapter};
|
|
|
|
|
use crate::config::AppConfig;
|
|
|
|
|
use crate::tools::ToolApi;
|
|
|
|
|
use crate::whatsapp::WhatsAppAdapter;
|
2025-10-11 20:02:14 -03:00
|
|
|
use diesel::PgConnection;
|
|
|
|
|
use redis::Client;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
use std::sync::Mutex;
|
2025-10-06 10:30:17 -03:00
|
|
|
|
|
|
|
|
pub struct AppState {
|
2025-10-11 12:29:03 -03:00
|
|
|
pub s3_client: Option<aws_sdk_s3::Client>,
|
2025-10-06 10:30:17 -03:00
|
|
|
pub config: Option<AppConfig>,
|
2025-10-11 12:29:03 -03:00
|
|
|
pub conn: Arc<Mutex<PgConnection>>,
|
2025-10-11 20:02:14 -03:00
|
|
|
pub custom_conn: Arc<Mutex<PgConnection>>,
|
|
|
|
|
|
2025-10-11 12:29:03 -03:00
|
|
|
pub redis_client: Option<Arc<Client>>,
|
2025-10-06 10:30:17 -03:00
|
|
|
pub orchestrator: Arc<BotOrchestrator>,
|
|
|
|
|
pub web_adapter: Arc<WebChannelAdapter>,
|
|
|
|
|
pub voice_adapter: Arc<VoiceAdapter>,
|
|
|
|
|
pub whatsapp_adapter: Arc<WhatsAppAdapter>,
|
|
|
|
|
pub tool_api: Arc<ToolApi>,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 12:29:03 -03:00
|
|
|
impl Clone for AppState {
|
|
|
|
|
fn clone(&self) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
s3_client: self.s3_client.clone(),
|
|
|
|
|
config: self.config.clone(),
|
|
|
|
|
conn: Arc::clone(&self.conn),
|
|
|
|
|
redis_client: self.redis_client.clone(),
|
|
|
|
|
orchestrator: Arc::clone(&self.orchestrator),
|
|
|
|
|
web_adapter: Arc::clone(&self.web_adapter),
|
|
|
|
|
voice_adapter: Arc::clone(&self.voice_adapter),
|
|
|
|
|
whatsapp_adapter: Arc::clone(&self.whatsapp_adapter),
|
|
|
|
|
tool_api: Arc::clone(&self.tool_api),
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-06 10:30:17 -03:00
|
|
|
}
|