pub struct SessionManager<T: Clone + DeserializeOwned, const N: usize = 8> { /* private fields */ }Expand description
Session manager for handling multiple concurrent connections to exchanges with failover, load balancing, and session persistence.
§Type Parameters
T: Message type that the session manager handlesN: Maximum number of concurrent sessions (default: 8) Optimized for typical HFT scenarios with multiple exchange connections
Implementations§
Source§impl<T: Clone + DeserializeOwned + Send + Sync + 'static, const N: usize> SessionManager<T, N>
impl<T: Clone + DeserializeOwned + Send + Sync + 'static, const N: usize> SessionManager<T, N>
Sourcepub fn new(
configs: SmallVec<[SessionConfig; N]>,
health_check_interval_milliseconds: u64,
channel_buffer_size: usize,
fast_switching_enabled: bool,
) -> Self
pub fn new( configs: SmallVec<[SessionConfig; N]>, health_check_interval_milliseconds: u64, channel_buffer_size: usize, fast_switching_enabled: bool, ) -> Self
Create a new session manager
Sourcepub fn active_session_index(&self) -> usize
pub fn active_session_index(&self) -> usize
Get the active session index
Sourcepub fn session_stats(&self, session_index: usize) -> Result<SessionStats>
pub fn session_stats(&self, session_index: usize) -> Result<SessionStats>
Get session statistics
Sourcepub fn all_session_stats(&self) -> Vec<SessionStats>
pub fn all_session_stats(&self) -> Vec<SessionStats>
Get all session statistics
Sourcepub fn session_state(&self, session_index: usize) -> Result<SessionState>
pub fn session_state(&self, session_index: usize) -> Result<SessionState>
Get session state
Sourcepub fn all_session_states(&self) -> Vec<SessionState>
pub fn all_session_states(&self) -> Vec<SessionState>
Get all session states
Sourcepub async fn switch_to_session(&mut self, session_index: usize) -> Result<()>
pub async fn switch_to_session(&mut self, session_index: usize) -> Result<()>
Manually switch to a different session
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the session manager is running
Sourcepub fn time_since_last_health_check(&self) -> Duration
pub fn time_since_last_health_check(&self) -> Duration
Get the time since the last health check
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Get the number of sessions
Sourcepub fn session_config(&self, session_index: usize) -> Result<&SessionConfig>
pub fn session_config(&self, session_index: usize) -> Result<&SessionConfig>
Get a reference to the session configuration
Sourcepub fn all_session_configs(&self) -> &[SessionConfig]
pub fn all_session_configs(&self) -> &[SessionConfig]
Get all session configurations
Trait Implementations§
Auto Trait Implementations§
impl<T, const N: usize> Freeze for SessionManager<T, N>
impl<T, const N: usize = 8> !RefUnwindSafe for SessionManager<T, N>
impl<T, const N: usize> Send for SessionManager<T, N>where
T: Send,
impl<T, const N: usize> Sync for SessionManager<T, N>where
T: Send,
impl<T, const N: usize> Unpin for SessionManager<T, N>
impl<T, const N: usize = 8> !UnwindSafe for SessionManager<T, N>
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
Mutably borrows from an owned value. Read more