gitdataai/libs/transport/metrics.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

41 lines
1.3 KiB
Rust

use std::sync::Arc;
#[derive(Clone)]
pub struct TransportMetrics {
pub messages_sent: Arc<std::sync::atomic::AtomicU64>,
pub messages_received: Arc<std::sync::atomic::AtomicU64>,
pub messages_failed: Arc<std::sync::atomic::AtomicU64>,
pub active_connections: Arc<std::sync::atomic::AtomicI64>,
}
impl TransportMetrics {
pub fn new() -> Self {
Self {
messages_sent: Arc::new(std::sync::atomic::AtomicU64::new(0)),
messages_received: Arc::new(std::sync::atomic::AtomicU64::new(0)),
messages_failed: Arc::new(std::sync::atomic::AtomicU64::new(0)),
active_connections: Arc::new(std::sync::atomic::AtomicI64::new(0)),
}
}
pub fn increment_sent(&self) {
self.messages_sent.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
pub fn increment_received(&self) {
self.messages_received.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
pub fn increment_failed(&self) {
self.messages_failed.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
pub fn increment_connections(&self) {
self.active_connections.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
pub fn decrement_connections(&self) {
self.active_connections.fetch_sub(1, std::sync::atomic::Ordering::Relaxed);
}
}