- Add gitignore and prettier configuration files for project scaffolding - Implement room access control service with project member verification - Create user access key management with CRUD operations and activity logging - Add accordion UI component for frontend expandable sections - Implement room AI configuration with list, upsert, and delete operations - Add AI event types for agent join/leave/status change tracking - Create streaming AI processing services for mode and react patterns - Build room AI service with model detection and idempotency handling - Integrate chat service orchestration for AI message processing - Add typing indicators and stream cancellation for AI interactions - Implement mention parsing and context extraction for AI agents
37 lines
938 B
Rust
37 lines
938 B
Rust
use config::AppConfig;
|
|
use deadpool_redis::cluster::{Connection, Manager, Pool};
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppCache {
|
|
pool: Pool,
|
|
redis_url: String,
|
|
}
|
|
|
|
impl AppCache {
|
|
pub async fn init(cfg: &AppConfig) -> anyhow::Result<Self> {
|
|
let urls = cfg.redis_urls()?;
|
|
let pool_size = cfg.redis_pool_size()?;
|
|
let conn = Manager::new(urls.clone(), true)?;
|
|
let pool = deadpool_redis::cluster::Pool::builder(conn)
|
|
.max_size(pool_size as usize)
|
|
.build()?;
|
|
let redis_url = urls
|
|
.first()
|
|
.cloned()
|
|
.unwrap_or_else(|| "redis://127.0.0.1:6379".to_string());
|
|
|
|
Ok(Self { pool, redis_url })
|
|
}
|
|
pub async fn conn(&self) -> anyhow::Result<Connection> {
|
|
Ok(self.pool.get().await?)
|
|
}
|
|
|
|
pub fn redis_pool(&self) -> &Pool {
|
|
&self.pool
|
|
}
|
|
|
|
pub fn redis_url(&self) -> &str {
|
|
&self.redis_url
|
|
}
|
|
}
|