pub struct SessionModeHandler { /* private fields */ }Expand description
Session mode handler
In session mode, a connection is held for the entire client session. This provides 1:1 client-to-backend mapping, which is:
- Safest for all PostgreSQL features
- Compatible with server-side prepared statements
- Compatible with LISTEN/NOTIFY
- Compatible with temp tables and session variables
The downside is less connection sharing between clients.
Implementations§
Source§impl SessionModeHandler
impl SessionModeHandler
Sourcepub fn with_prepared_tracking() -> Self
pub fn with_prepared_tracking() -> Self
Create with prepared statement tracking enabled
Sourcepub fn create_lease(
&self,
connection: PooledConnection,
client_id: ClientId,
) -> ConnectionLease
pub fn create_lease( &self, connection: PooledConnection, client_id: ClientId, ) -> ConnectionLease
Create a lease for this mode
Sourcepub fn on_statement_complete(
&self,
_lease: &mut ConnectionLease,
_sql: &str,
) -> LeaseAction
pub fn on_statement_complete( &self, _lease: &mut ConnectionLease, _sql: &str, ) -> LeaseAction
Process a statement and determine action
Session mode always holds the connection.
Sourcepub fn on_transaction_end(&self, _lease: &mut ConnectionLease) -> LeaseAction
pub fn on_transaction_end(&self, _lease: &mut ConnectionLease) -> LeaseAction
Process transaction end
Session mode always holds the connection.
Sourcepub fn should_release(&self, _lease: &ConnectionLease) -> bool
pub fn should_release(&self, _lease: &ConnectionLease) -> bool
Check if connection should be released
Session mode never releases until client disconnects.
Sourcepub fn on_client_disconnect(&self, _lease: ConnectionLease) -> LeaseAction
pub fn on_client_disconnect(&self, _lease: ConnectionLease) -> LeaseAction
Called when client disconnects
Sourcepub fn mode(&self) -> PoolingMode
pub fn mode(&self) -> PoolingMode
Get the pooling mode
Sourcepub fn tracks_prepared_statements(&self) -> bool
pub fn tracks_prepared_statements(&self) -> bool
Check if prepared statement tracking is enabled
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionModeHandler
impl RefUnwindSafe for SessionModeHandler
impl Send for SessionModeHandler
impl Sync for SessionModeHandler
impl Unpin for SessionModeHandler
impl UnsafeUnpin for SessionModeHandler
impl UnwindSafe for SessionModeHandler
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
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>
Converts
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>
Converts
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 more