pub struct Session {
id: SessionId,
is_mcp: bool,
last_activity: Mutex<Instant>,
sender: UnboundedSender<(UnboundedSender<Response>, Command)>,
connection_count: AtomicU32,
shutdown_requested: AtomicBool,
pack_names: RwLock<Vec<String>>,
}Expand description
A session represents a single client’s connection state.
Each session has its own background thread for processing commands, ensuring complete isolation between clients.
Fields§
§id: SessionIdUnique identifier for this session.
is_mcp: boolWhether this session was created for an MCP client.
MCP sessions have no disconnect signal (the MCP transport keeps the session registered until the client sends an HTTP DELETE, which many clients never do), so they are reaped based on command inactivity instead of connection count.
last_activity: Mutex<Instant>Instant of the last command sent to this session’s background thread.
Only updated by Session::send, so it reflects actual work, not
transport-level pings.
sender: UnboundedSender<(UnboundedSender<Response>, Command)>Sender to communicate with this session’s background thread.
connection_count: AtomicU32Number of active connections using this session.
shutdown_requested: AtomicBoolWhether this session has been marked for shutdown.
pack_names: RwLock<Vec<String>>Names of the pack files currently open in this session.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(id: SessionId, is_mcp: bool) -> Arc<Self> ⓘ
pub fn new(id: SessionId, is_mcp: bool) -> Arc<Self> ⓘ
Create a new session with its own background thread.
is_mcp marks sessions created for MCP clients, which are reaped by
inactivity instead of by connection count (see Session::is_mcp).
Sourcepub fn last_activity(&self) -> Instant
pub fn last_activity(&self) -> Instant
Get the instant of the last command sent to this session.
Sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Decrement the connection count.
Sourcepub fn connection_count(&self) -> u32
pub fn connection_count(&self) -> u32
Get the current connection count.
Sourcepub fn is_shutdown_requested(&self) -> bool
pub fn is_shutdown_requested(&self) -> bool
Check if shutdown has been requested.
Sourcepub fn pack_names(&self) -> Vec<String>
pub fn pack_names(&self) -> Vec<String>
Get the pack names for this session.
Sourcepub fn add_pack_name(&self, name: &str)
pub fn add_pack_name(&self, name: &str)
Add a pack name to this session.
Sourcepub fn remove_pack_name(&self, name: &str)
pub fn remove_pack_name(&self, name: &str)
Remove a pack name from this session.
Auto Trait Implementations§
impl !Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for T
impl<T> MaybeSync for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.