pub struct ApplicationState {
pub Configuration: Arc<AirConfiguration>,
pub ServiceStatus: Arc<RwLock<HashMap<String, ServiceStatus>>>,
pub ActiveRequests: Arc<Mutex<HashMap<String, RequestStatus>>>,
pub Metrics: Arc<RwLock<PerformanceMetrics>>,
pub Resources: Arc<RwLock<ResourceUsage>>,
pub Connections: Arc<RwLock<HashMap<String, ConnectionInfo>>>,
pub BackgroundTasks: Arc<Mutex<Vec<JoinHandle<()>>>>,
}Expand description
Application state structure
Fields§
§Configuration: Arc<AirConfiguration>Current configuration
ServiceStatus: Arc<RwLock<HashMap<String, ServiceStatus>>>Service status tracking
ActiveRequests: Arc<Mutex<HashMap<String, RequestStatus>>>Active requests tracking
Metrics: Arc<RwLock<PerformanceMetrics>>Performance metrics
Resources: Arc<RwLock<ResourceUsage>>Resource usage tracking
Connections: Arc<RwLock<HashMap<String, ConnectionInfo>>>Connection tracking for Mountain clients
BackgroundTasks: Arc<Mutex<Vec<JoinHandle<()>>>>Background task management
Implementations§
Source§impl ApplicationState
impl ApplicationState
Sourcepub async fn New(Configuration: Arc<AirConfiguration>) -> Result<Self>
pub async fn New(Configuration: Arc<AirConfiguration>) -> Result<Self>
Create a new ApplicationState instance
Sourcepub async fn RegisterConnection(
&self,
ConnectionId: String,
ClientId: String,
ClientVersion: String,
ProtocolVersion: u32,
ConnectionType: ConnectionType,
) -> Result<()>
pub async fn RegisterConnection( &self, ConnectionId: String, ClientId: String, ClientVersion: String, ProtocolVersion: u32, ConnectionType: ConnectionType, ) -> Result<()>
Register a new connection with comprehensive validation Supports connection pooling for Mountain clients
Sourcepub async fn UpdateHeartbeat(&self, ConnectionId: &str) -> Result<()>
pub async fn UpdateHeartbeat(&self, ConnectionId: &str) -> Result<()>
Update connection heartbeat with validation Validates heartbeat timing and connection state
Sourcepub async fn RemoveConnection(&self, ConnectionId: &str) -> Result<()>
pub async fn RemoveConnection(&self, ConnectionId: &str) -> Result<()>
Remove connection with proper cleanup and validation Ensures all resources associated with the connection are cleaned up
Sourcepub async fn GetActiveConnectionCount(&self) -> usize
pub async fn GetActiveConnectionCount(&self) -> usize
Get active connection count with optional filtering by type
Sourcepub async fn GetConnectionCountByType(
&self,
ConnectionType: ConnectionType,
) -> usize
pub async fn GetConnectionCountByType( &self, ConnectionType: ConnectionType, ) -> usize
Get connection count by type
Sourcepub async fn GetConnectionsByType(
&self,
ConnectionType: ConnectionType,
) -> Vec<ConnectionInfo>
pub async fn GetConnectionsByType( &self, ConnectionType: ConnectionType, ) -> Vec<ConnectionInfo>
Get connections by type
Sourcepub async fn GetNextMountainConnection(&self) -> Result<ConnectionInfo>
pub async fn GetNextMountainConnection(&self) -> Result<ConnectionInfo>
Get connection for load balancing from Mountain pool Implements simple round-robin selection for connection pooling
Sourcepub async fn CleanupStaleConnections(
&self,
TimeoutSeconds: u64,
) -> Result<usize>
pub async fn CleanupStaleConnections( &self, TimeoutSeconds: u64, ) -> Result<usize>
Clean up stale connections with comprehensive tracking Removes connections that haven’t sent a heartbeat within the timeout period
Sourcepub async fn RegisterBackgroundTask(&self, Task: JoinHandle<()>) -> Result<()>
pub async fn RegisterBackgroundTask(&self, Task: JoinHandle<()>) -> Result<()>
Register background task with tracking
Sourcepub async fn StopAllBackgroundTasks(&self) -> Result<()>
pub async fn StopAllBackgroundTasks(&self) -> Result<()>
Stop all background tasks with graceful shutdown
Sourcepub async fn UpdateServiceStatus(
&self,
Service: &str,
Status: ServiceStatus,
) -> Result<()>
pub async fn UpdateServiceStatus( &self, Service: &str, Status: ServiceStatus, ) -> Result<()>
Update service status with validation
Sourcepub async fn GetServiceStatus(&self, Service: &str) -> Option<ServiceStatus>
pub async fn GetServiceStatus(&self, Service: &str) -> Option<ServiceStatus>
Get service status
Sourcepub async fn GetAllServiceStatuses(&self) -> HashMap<String, ServiceStatus>
pub async fn GetAllServiceStatuses(&self) -> HashMap<String, ServiceStatus>
Get all service statuses
Sourcepub async fn RegisterRequest(
&self,
RequestId: String,
Service: String,
) -> Result<()>
pub async fn RegisterRequest( &self, RequestId: String, Service: String, ) -> Result<()>
Register a new request with validation
Sourcepub async fn UpdateRequestStatus(
&self,
RequestId: &str,
Status: RequestState,
Progress: Option<f32>,
) -> Result<()>
pub async fn UpdateRequestStatus( &self, RequestId: &str, Status: RequestState, Progress: Option<f32>, ) -> Result<()>
Update request status with validation
Sourcepub async fn RemoveRequest(&self, RequestId: &str) -> Result<()>
pub async fn RemoveRequest(&self, RequestId: &str) -> Result<()>
Remove completed request with validation
Sourcepub async fn UpdateMetrics(
&self,
Success: bool,
ResponseTime: u64,
) -> Result<()>
pub async fn UpdateMetrics( &self, Success: bool, ResponseTime: u64, ) -> Result<()>
Update performance metrics with validation
Sourcepub async fn UpdateResourceUsage(&self) -> Result<()>
pub async fn UpdateResourceUsage(&self) -> Result<()>
Update resource usage with error handling
Sourcepub async fn GetMetrics(&self) -> PerformanceMetrics
pub async fn GetMetrics(&self) -> PerformanceMetrics
Get performance metrics
Sourcepub async fn GetResourceUsage(&self) -> ResourceUsage
pub async fn GetResourceUsage(&self) -> ResourceUsage
Get resource usage
Sourcepub async fn GetActiveRequestCount(&self) -> usize
pub async fn GetActiveRequestCount(&self) -> usize
Get active request count
Sourcepub async fn IsRequestCancelled(&self, RequestId: &str) -> bool
pub async fn IsRequestCancelled(&self, RequestId: &str) -> bool
Check if a request is cancelled
Sourcepub async fn GetConfiguration(&self) -> Arc<AirConfiguration>
pub async fn GetConfiguration(&self) -> Arc<AirConfiguration>
Get current configuration
Sourcepub async fn UpdateConfiguration(
&self,
Section: String,
Updates: HashMap<String, String>,
) -> Result<()>
pub async fn UpdateConfiguration( &self, Section: String, Updates: HashMap<String, String>, ) -> Result<()>
Update configuration with validation and atomic operations
Sourcepub async fn SetResourceLimits(
&self,
MemoryLimitMb: Option<u64>,
CPULimitPercent: Option<f64>,
DiskLimitMb: Option<u64>,
) -> Result<()>
pub async fn SetResourceLimits( &self, MemoryLimitMb: Option<u64>, CPULimitPercent: Option<f64>, DiskLimitMb: Option<u64>, ) -> Result<()>
Set resource limits with validation and enforcement
Sourcepub async fn CheckResourceLimits(&self) -> Result<bool>
pub async fn CheckResourceLimits(&self) -> Result<bool>
Check if resource limits are exceeded
Sourcepub async fn GetConnectionHealthReport(&self) -> ConnectionHealthReport
pub async fn GetConnectionHealthReport(&self) -> ConnectionHealthReport
Get connection health report
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApplicationState
impl !RefUnwindSafe for ApplicationState
impl Send for ApplicationState
impl Sync for ApplicationState
impl Unpin for ApplicationState
impl !UnwindSafe for ApplicationState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].