1
//! Per-user connection routing.
2
//!
3
//! [`registry`] owns the bookkeeping — residency, expiry and eviction — and is
4
//! always compiled so it can be tested directly. [`live`] holds everything that
5
//! touches a database and is excluded from server's own `cfg(test)` runs, where
6
//! `User::get_connection` short-circuits to the injected test pool.
7

            
8
pub(crate) mod registry;
9

            
10
#[cfg(not(test))]
11
mod live;
12

            
13
#[cfg(not(test))]
14
pub(in crate::user) use live::get_connection;
15

            
16
/// Connections of the tenant pools resident in this process.
17
#[cfg(not(test))]
18
pub(crate) fn tenant_usage() -> crate::telemetry::pools::PoolUsage {
19
    live::usage()
20
}
21

            
22
/// Server's own tests never build tenant pools.
23
#[cfg(test)]
24
3
pub(crate) fn tenant_usage() -> crate::telemetry::pools::PoolUsage {
25
3
    crate::telemetry::pools::PoolUsage::default()
26
3
}