pub struct SessionManager<T> { /* private fields */ }Expand description
Generic session manager for protocol-agnostic session coordination
Time System: Uses PhysicalTime for timestamps per the unified time architecture.
Implementations§
Source§impl<T> SessionManager<T>
impl<T> SessionManager<T>
Sourcepub fn new(config: SessionConfig, now: PhysicalTime) -> Self
pub fn new(config: SessionConfig, now: PhysicalTime) -> Self
Create a new session manager
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn new_from_ms(config: SessionConfig, now_ms: u64) -> Self
pub fn new_from_ms(config: SessionConfig, now_ms: u64) -> Self
Create a new session manager from milliseconds timestamp
Convenience constructor for backward compatibility.
Sourcepub fn with_metrics(
config: SessionConfig,
metrics: MetricsCollector,
now: PhysicalTime,
) -> Self
pub fn with_metrics( config: SessionConfig, metrics: MetricsCollector, now: PhysicalTime, ) -> Self
Create session manager with metrics collection
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn create_session(
&mut self,
participants: Vec<DeviceId>,
now: &PhysicalTime,
) -> SyncResult<SessionId>
pub fn create_session( &mut self, participants: Vec<DeviceId>, now: &PhysicalTime, ) -> SyncResult<SessionId>
Create a new session with participants
Time System: Uses PhysicalTime for timestamps.
Note: Callers should obtain now via their time provider and pass it to this method
Sourcepub fn create_session_ms(
&mut self,
participants: Vec<DeviceId>,
now_ms: u64,
) -> SyncResult<SessionId>
pub fn create_session_ms( &mut self, participants: Vec<DeviceId>, now_ms: u64, ) -> SyncResult<SessionId>
Create a new session with participants (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn activate_session(
&mut self,
session_id: SessionId,
protocol_state: T,
current_time: &PhysicalTime,
) -> SyncResult<()>
pub fn activate_session( &mut self, session_id: SessionId, protocol_state: T, current_time: &PhysicalTime, ) -> SyncResult<()>
Activate a session with initial protocol state
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn activate_session_ms(
&mut self,
session_id: SessionId,
protocol_state: T,
current_timestamp_ms: u64,
) -> SyncResult<()>
pub fn activate_session_ms( &mut self, session_id: SessionId, protocol_state: T, current_timestamp_ms: u64, ) -> SyncResult<()>
Activate a session with initial protocol state (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn update_session(
&mut self,
session_id: SessionId,
new_state: T,
current_time: &PhysicalTime,
) -> SyncResult<()>where
T: Debug,
pub fn update_session(
&mut self,
session_id: SessionId,
new_state: T,
current_time: &PhysicalTime,
) -> SyncResult<()>where
T: Debug,
Update session protocol state
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn update_session_ms(
&mut self,
session_id: SessionId,
new_state: T,
current_timestamp_ms: u64,
) -> SyncResult<()>where
T: Debug,
pub fn update_session_ms(
&mut self,
session_id: SessionId,
new_state: T,
current_timestamp_ms: u64,
) -> SyncResult<()>where
T: Debug,
Update session protocol state (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn complete_session(
&mut self,
session_id: SessionId,
operations_count: u64,
bytes_transferred: u64,
metadata: HashMap<String, String>,
current_time: &PhysicalTime,
) -> SyncResult<()>
pub fn complete_session( &mut self, session_id: SessionId, operations_count: u64, bytes_transferred: u64, metadata: HashMap<String, String>, current_time: &PhysicalTime, ) -> SyncResult<()>
Complete a session successfully
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn complete_session_ms(
&mut self,
session_id: SessionId,
operations_count: u64,
bytes_transferred: u64,
metadata: HashMap<String, String>,
current_timestamp_ms: u64,
) -> SyncResult<()>
pub fn complete_session_ms( &mut self, session_id: SessionId, operations_count: u64, bytes_transferred: u64, metadata: HashMap<String, String>, current_timestamp_ms: u64, ) -> SyncResult<()>
Complete a session successfully (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn fail_session(
&mut self,
session_id: SessionId,
error: SessionError,
partial_results: Option<PartialResults>,
current_time: &PhysicalTime,
) -> SyncResult<()>
pub fn fail_session( &mut self, session_id: SessionId, error: SessionError, partial_results: Option<PartialResults>, current_time: &PhysicalTime, ) -> SyncResult<()>
Fail a session with error context
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn fail_session_ms(
&mut self,
session_id: SessionId,
error: SessionError,
partial_results: Option<PartialResults>,
current_timestamp_ms: u64,
) -> SyncResult<()>
pub fn fail_session_ms( &mut self, session_id: SessionId, error: SessionError, partial_results: Option<PartialResults>, current_timestamp_ms: u64, ) -> SyncResult<()>
Fail a session with error context (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn timeout_session(
&mut self,
session_id: SessionId,
current_time: &PhysicalTime,
) -> SyncResult<()>where
T: Debug,
pub fn timeout_session(
&mut self,
session_id: SessionId,
current_time: &PhysicalTime,
) -> SyncResult<()>where
T: Debug,
Timeout a session
Time System: Uses PhysicalTime for timestamps.
Sourcepub fn timeout_session_ms(
&mut self,
session_id: SessionId,
current_timestamp_ms: u64,
) -> SyncResult<()>where
T: Debug,
pub fn timeout_session_ms(
&mut self,
session_id: SessionId,
current_timestamp_ms: u64,
) -> SyncResult<()>where
T: Debug,
Timeout a session (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn get_session(&self, session_id: &SessionId) -> Option<&SessionState<T>>
pub fn get_session(&self, session_id: &SessionId) -> Option<&SessionState<T>>
Get session state
Sourcepub fn get_protocol_state(&self, session_id: &SessionId) -> Option<&T>
pub fn get_protocol_state(&self, session_id: &SessionId) -> Option<&T>
Get protocol state for active session
Sourcepub fn active_sessions(&self) -> Vec<(SessionId, &SessionState<T>)>
pub fn active_sessions(&self) -> Vec<(SessionId, &SessionState<T>)>
List all active sessions
Sourcepub fn count_active_sessions(&self) -> usize
pub fn count_active_sessions(&self) -> usize
Count active sessions
Sourcepub fn count_completed_sessions(&self) -> usize
pub fn count_completed_sessions(&self) -> usize
Count completed sessions
Sourcepub fn cleanup_stale_sessions(
&mut self,
now: &PhysicalTime,
) -> SyncResult<usize>where
T: Debug,
pub fn cleanup_stale_sessions(
&mut self,
now: &PhysicalTime,
) -> SyncResult<usize>where
T: Debug,
Cleanup stale and completed sessions
Time System: Uses PhysicalTime for timestamps.
Note: Callers should obtain now via their time provider and pass it to this method
Sourcepub fn cleanup_stale_sessions_ms(&mut self, now_ms: u64) -> SyncResult<usize>where
T: Debug,
pub fn cleanup_stale_sessions_ms(&mut self, now_ms: u64) -> SyncResult<usize>where
T: Debug,
Cleanup stale and completed sessions (from milliseconds)
Convenience method for backward compatibility.
Sourcepub fn get_statistics(&self) -> SessionManagerStatistics
pub fn get_statistics(&self) -> SessionManagerStatistics
Get session statistics
Sourcepub fn close_session(&mut self, peer: DeviceId) -> SyncResult<()>
pub fn close_session(&mut self, peer: DeviceId) -> SyncResult<()>
Close a session for a specific peer
Sourcepub fn has_active_session(&self, peer: DeviceId) -> bool
pub fn has_active_session(&self, peer: DeviceId) -> bool
Check if peer has an active session