gitdataai/libs/config/nats.rs
ZhenYi 14f6e1e500 feat(core): initialize project with access control and AI integration
- 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
2026-05-03 06:04:31 +08:00

51 lines
1.2 KiB
Rust

use crate::AppConfig;
impl AppConfig {
pub fn nats_url(&self) -> Option<String> {
self.env.get("NATS_URL").cloned()
}
pub fn nats_token(&self) -> Option<String> {
self.env.get("NATS_TOKEN").cloned()
}
pub fn nats_stream_name(&self) -> String {
self.env
.get("NATS_STREAM_NAME")
.cloned()
.unwrap_or_else(|| "ROOM_EVENTS".to_string())
}
pub fn nats_max_deliver(&self) -> i64 {
self.env
.get("NATS_MAX_DELIVER")
.and_then(|v| v.parse().ok())
.unwrap_or(3)
}
pub fn nats_ack_wait_secs(&self) -> u64 {
self.env
.get("NATS_ACK_WAIT_SECS")
.and_then(|v| v.parse().ok())
.unwrap_or(10)
}
pub fn nats_max_age_secs(&self) -> u64 {
self.env
.get("NATS_MAX_AGE_SECS")
.and_then(|v| v.parse().ok())
.unwrap_or(86_400)
}
pub fn nats_buffer_size(&self) -> usize {
self.env
.get("NATS_BUFFER_SIZE")
.and_then(|v| v.parse().ok())
.unwrap_or(256)
}
pub fn nats_is_enabled(&self) -> bool {
self.nats_url().is_some() && self.nats_token().is_some()
}
}