Skip to main content

DataSource

Trait DataSource 

Source
pub trait DataSource:
    Send
    + Sync
    + 'static {
    type Conn: Send;

    // Required methods
    fn acquire(
        &self,
        intent: AccessIntent,
    ) -> BoxFuture<'_, Result<Self::Conn, DataError>>;
    fn name(&self) -> &'static str;
}
Expand description

One logical database: a primary plus optional read replicas.

Implementations own pooling (SQLx PgPools etc.) and replica selection. acquire(Write) MUST return a primary connection; acquire(Read) MAY return a replica.

Required Associated Types§

Required Methods§

Source

fn acquire( &self, intent: AccessIntent, ) -> BoxFuture<'_, Result<Self::Conn, DataError>>

Source

fn name(&self) -> &'static str

Logical name (matches TenantConfig::datasource). For logs/metrics.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§