pub struct GraphSessionManager { /* private fields */ }Implementations§
Source§impl GraphSessionManager
impl GraphSessionManager
Sourcepub fn new(
host_addr: String,
max_connections: usize,
session_idle_timeout: Duration,
) -> Arc<Self> ⓘ
pub fn new( host_addr: String, max_connections: usize, session_idle_timeout: Duration, ) -> Arc<Self> ⓘ
Create a new session manager.
This constructor does not automatically initiate background cleanup tasks.
Need to explicitly call start_cleanup_task() to start
Build a manager sharing one session-event registry with QueryManager.
Shared session-event registry behind this manager.
Sourcepub fn mask_session_id(session_id: i64) -> String
pub fn mask_session_id(session_id: i64) -> String
Mask a session id for logs: prefix plus a short hash only.
Sourcepub fn idle_timeout(&self) -> Duration
pub fn idle_timeout(&self) -> Duration
Session idle timeout driving reclamation and expiry responses.
Sourcepub fn set_default_auto_commit(&self, auto_commit: bool)
pub fn set_default_auto_commit(&self, auto_commit: bool)
Set the auto-commit mode applied to sessions created from now on.
Point this manager at a shared session-event registry.
The field is an Arc, so an already-published instance needs &mut
access to switch sources; managers behind Arc should prefer
new_with_shared at construction time instead.
Sourcepub fn register_session_callback(
&self,
callback: SessionEventCallback,
) -> SubscriptionId
pub fn register_session_callback( &self, callback: SessionEventCallback, ) -> SubscriptionId
Register a runtime observer for session lifecycle events.
Sourcepub fn register_session_callback_filtered(
&self,
callback: SessionEventCallback,
filter: EventFilter<SessionEvent>,
) -> SubscriptionId
pub fn register_session_callback_filtered( &self, callback: SessionEventCallback, filter: EventFilter<SessionEvent>, ) -> SubscriptionId
Register a filtered observer invoked only when filter returns true.
Sourcepub fn unregister_session_callback(&self, id: SubscriptionId) -> bool
pub fn unregister_session_callback(&self, id: SubscriptionId) -> bool
Remove a previously registered observer. Returns true if present.
Sourcepub fn session_callback_count(&self) -> usize
pub fn session_callback_count(&self) -> usize
Number of registered session observers.
Sourcepub async fn start_cleanup_task(self: &Arc<Self>)
pub async fn start_cleanup_task(self: &Arc<Self>)
Start the background session cleanup task.
If the task is already running, this method will not start it again.
Sourcepub fn stop_cleanup_task(&self)
pub fn stop_cleanup_task(&self)
Stop the background session cleaning task.
Set a stop flag; the background task will exit during the next iteration.
Sourcepub fn is_cleanup_task_running(&self) -> bool
pub fn is_cleanup_task_running(&self) -> bool
Check whether the background cleanup task is currently running.
Sourcepub async fn create_session(
&self,
user_name: String,
_client_ip: String,
) -> Result<Arc<ClientSession>, String>
pub async fn create_session( &self, user_name: String, _client_ip: String, ) -> Result<Arc<ClientSession>, String>
Creates a new session
Sourcepub fn find_session(&self, session_id: i64) -> Option<Arc<ClientSession>>
pub fn find_session(&self, session_id: i64) -> Option<Arc<ClientSession>>
Finds an existing session
Sourcepub fn find_session_from_cache(
&self,
session_id: i64,
) -> Option<Arc<ClientSession>>
pub fn find_session_from_cache( &self, session_id: i64, ) -> Option<Arc<ClientSession>>
Finds an existing session only from local cache
Sourcepub async fn remove_session(&self, session_id: i64)
pub async fn remove_session(&self, session_id: i64)
Removes a session from local cache
Sourcepub async fn remove_sessions_by_username(
&self,
username: &str,
except_session_id: Option<i64>,
) -> Vec<i64>
pub async fn remove_sessions_by_username( &self, username: &str, except_session_id: Option<i64>, ) -> Vec<i64>
Invalidate all sessions of a user, optionally keeping one session.
Used when a user is disabled or dropped so existing sessions stop working immediately. Returns the removed session ids.
Sourcepub fn get_sessions_from_local_cache(&self) -> Vec<Session>
pub fn get_sessions_from_local_cache(&self) -> Vec<Session>
Gets all sessions from the local cache
Sourcepub async fn list_sessions(&self) -> Vec<SessionInfo>
pub async fn list_sessions(&self) -> Vec<SessionInfo>
Obtain information about the session list, which is used for the SHOW SESSIONS command.
Sourcepub async fn get_session_info(&self, session_id: i64) -> Option<SessionInfo>
pub async fn get_session_info(&self, session_id: i64) -> Option<SessionInfo>
Obtain detailed information about the specified session.
Sourcepub async fn kill_session(
&self,
session_id: i64,
current_user: &str,
is_admin: bool,
) -> SessionResult<()>
pub async fn kill_session( &self, session_id: i64, current_user: &str, is_admin: bool, ) -> SessionResult<()>
Terminate the specified session (KILL SESSION)
§Parameters
session_id – The ID of the session that needs to be terminated.
current_user – The username of the user who is performing the termination operation.
is_admin – Determines whether the current user has the Admin role.
§Return
Ok(())- Successfully terminate the sessionErr(SessionError)- Specific reasons for termination failure
Sourcepub async fn kill_multiple_sessions(
&self,
session_ids: &[i64],
current_user: &str,
is_admin: bool,
) -> Vec<SessionResult<()>> ⓘ
pub async fn kill_multiple_sessions( &self, session_ids: &[i64], current_user: &str, is_admin: bool, ) -> Vec<SessionResult<()>> ⓘ
Batch termination of multiple sessions
Sourcepub async fn is_out_of_connections(&self) -> bool
pub async fn is_out_of_connections(&self) -> bool
Whether exceeds the max allowed connections
Sourcepub async fn active_session_count(&self) -> usize
pub async fn active_session_count(&self) -> usize
Obtain the number of active sessions
Sourcepub fn total_sessions_created(&self) -> u64
pub fn total_sessions_created(&self) -> u64
Cumulative number of sessions created since process start.
Sourcepub fn max_connections(&self) -> usize
pub fn max_connections(&self) -> usize
Obtaining the maximum limit for the number of connections
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GraphSessionManager
impl !RefUnwindSafe for GraphSessionManager
impl !UnwindSafe for GraphSessionManager
impl Send for GraphSessionManager
impl Sync for GraphSessionManager
impl Unpin for GraphSessionManager
impl UnsafeUnpin for GraphSessionManager
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.