Skip to main content

TransactionManager

Trait TransactionManager 

Source
pub trait TransactionManager:
    Any
    + Send
    + Sync
    + 'static {
    // Required methods
    fn datasource(&self) -> &str;
    fn open_session(&self) -> OpenSessionFuture<'_>;
    fn acquire_deadline(&self) -> Duration;
}
Expand description

Provider-neutral factory for transaction sessions on one datasource.

Implemented by the sql component (slice 2) and resolved by datasource name from the camel-core registry. camel-api never sees a driver or a SQL value model: slice 2 keeps statement execution in its own extension trait over the concrete session type.

Send + Sync + 'static lets the registry hold the manager in an Arc and share it across workers. TransactionManager::open_session returns a boxed future so the trait object is object safe. The Any supertrait lets boot-time registration tests recover the concrete manager from the registry by trait-object upcast, exactly like TransactionSession; it is auto-implemented, so implementors carry no extra burden.

Required Methods§

Source

fn datasource(&self) -> &str

Datasource name this manager serves.

The registry keys managers by this name, and load validation reports it in every typed error.

Source

fn open_session(&self) -> OpenSessionFuture<'_>

Open a session on this manager’s datasource.

Opening borrows a pooled connection but SHALL NOT send BEGIN: begin is lazy and driven by TransactionSession::begin at the first joined sql step. Registry resolution failures surface as TransactionError::ManagerMissing before this method is reached.

Source

fn acquire_deadline(&self) -> Duration

Bound for connection acquisition, normally the datasource acquire_timeout.

Slice 2 compares this deadline with the block timeout and reports the deadline that elapses first (requirement “Pool exhaustion is bounded and named”, “Block timeout”).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§