pub trait TenantDatabases: Send + Sync {
// Required method
fn database<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant: &'life1 Tenant,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Database>, TenantDbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
How a deployment turns a resolved tenant into a database handle.
Separate from ResolveTenant because the two answers come from
different places and fail differently: resolution reads a registry row
(cheap, cacheable, and a miss means 404), while this opens or reuses
a connection pool (lazy, evictable, and a failure means the tenant is
unreachable rather than unknown).
Implemented by the runtime, never by a module. The registry that backs
it is the only thing in the process that knows a DSN
(TENANT-ROUTING.md §4): it maps a connect failure to
TenantDbError::Unreachable before the URL can reach a log line
or a response body. Display for DbError already scrubs, so that is
not the only defence — but Debug derives raw, and a DSN formatted
before it ever becomes a DbError is scrubbed by nothing. Not
producing the string is the first line; the sink is the second.
Required Methods§
Sourcefn database<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant: &'life1 Tenant,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Database>, TenantDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn database<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant: &'life1 Tenant,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Database>, TenantDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The handle for tenant, opening its pool on first use.
§Errors
TenantDbError::Unreachable when the tenant’s database cannot be
reached. The DSN is never part of the error.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".