pub struct TransactionModeHandler { /* private fields */ }Expand description
Transaction mode handler
In transaction mode, connections are held for the duration of a transaction and returned to the pool after COMMIT or ROLLBACK.
Benefits:
- Good balance between connection sharing and compatibility
- Works with most PostgreSQL features within a transaction
- Supports prepared statements (with tracking/recreation)
Limitations:
- LISTEN/NOTIFY listeners are lost between transactions
- Session-level settings may need to be re-applied
- Temp tables persist but may not be on same connection
Implementations§
Source§impl TransactionModeHandler
impl TransactionModeHandler
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(
&mut self,
lease: &mut ConnectionLease,
sql: &str,
) -> LeaseAction
pub fn on_statement_complete( &mut self, lease: &mut ConnectionLease, sql: &str, ) -> LeaseAction
Process a statement and determine action
Returns the connection on COMMIT/ROLLBACK outside of savepoints.
Sourcepub fn on_transaction_end(&self, lease: &mut ConnectionLease) -> LeaseAction
pub fn on_transaction_end(&self, lease: &mut ConnectionLease) -> LeaseAction
Process transaction end signal from backend
Sourcepub fn should_release(&self, lease: &ConnectionLease) -> bool
pub fn should_release(&self, lease: &ConnectionLease) -> bool
Check if connection should be released
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
Sourcepub fn prepared_tracker(&self) -> Option<&PreparedStatementTracker>
pub fn prepared_tracker(&self) -> Option<&PreparedStatementTracker>
Get prepared statement tracker
Sourcepub fn prepared_tracker_mut(&mut self) -> Option<&mut PreparedStatementTracker>
pub fn prepared_tracker_mut(&mut self) -> Option<&mut PreparedStatementTracker>
Get mutable prepared statement tracker
Sourcepub fn get_prepared_recreation_sql(&self) -> Vec<String>
pub fn get_prepared_recreation_sql(&self) -> Vec<String>
Get SQL to recreate prepared statements on a new connection
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransactionModeHandler
impl RefUnwindSafe for TransactionModeHandler
impl Send for TransactionModeHandler
impl Sync for TransactionModeHandler
impl Unpin for TransactionModeHandler
impl UnsafeUnpin for TransactionModeHandler
impl UnwindSafe for TransactionModeHandler
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