pub struct SessionInfo { /* private fields */ }Expand description
Information about an active session’s lifecycle state.
Tracks activity metrics used for determining when to close sessions based on duration limits, message counts, or inactivity timeouts.
§Examples
use queue_runtime::{SessionInfo, SessionId};
use std::time::Duration;
let session_id = SessionId::new("order-123".to_string()).unwrap();
let mut info = SessionInfo::new(session_id.clone(), "worker-1".to_string());
// Record message processing
info.increment_message_count();
info.increment_message_count();
// Check duration
assert!(info.duration() < Duration::from_secs(1));
// Check message count
assert_eq!(info.message_count(), 2);Implementations§
Source§impl SessionInfo
impl SessionInfo
Sourcepub fn new(session_id: SessionId, consumer_id: String) -> Self
pub fn new(session_id: SessionId, consumer_id: String) -> Self
Create a new session info tracker.
Sourcepub fn session_id(&self) -> &SessionId
pub fn session_id(&self) -> &SessionId
Get the session ID.
Sourcepub fn consumer_id(&self) -> &str
pub fn consumer_id(&self) -> &str
Get the consumer ID.
Sourcepub fn started_at(&self) -> Instant
pub fn started_at(&self) -> Instant
Get the time when this session was started.
Sourcepub fn last_activity(&self) -> Instant
pub fn last_activity(&self) -> Instant
Get the time of last activity in this session.
Sourcepub fn message_count(&self) -> u32
pub fn message_count(&self) -> u32
Get the number of messages processed in this session.
Sourcepub fn increment_message_count(&mut self)
pub fn increment_message_count(&mut self)
Record message processing activity.
Trait Implementations§
Source§impl Clone for SessionInfo
impl Clone for SessionInfo
Source§fn clone(&self) -> SessionInfo
fn clone(&self) -> SessionInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SessionInfo
impl RefUnwindSafe for SessionInfo
impl Send for SessionInfo
impl Sync for SessionInfo
impl Unpin for SessionInfo
impl UnsafeUnpin for SessionInfo
impl UnwindSafe for SessionInfo
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