pub struct Tools { /* private fields */ }Expand description
构建完成后冻结的应用资源。
Implementations§
Source§impl Tools
impl Tools
Sourcepub fn state(&self) -> ToolsState
pub fn state(&self) -> ToolsState
返回当前生命周期状态。
Sourcepub fn database(&self) -> Result<&AnyDatabase, BaseError>
pub fn database(&self) -> Result<&AnyDatabase, BaseError>
获取默认数据源;未配置或生命周期已结束时失败。
Sourcepub fn datasource(&self, id: &DatasourceId) -> Result<&Datasource, BaseError>
pub fn datasource(&self, id: &DatasourceId) -> Result<&Datasource, BaseError>
按逻辑名获取数据源;未配置、未注册或生命周期已结束时失败。
Sourcepub fn database_named(
&self,
id: &DatasourceId,
) -> Result<&AnyDatabase, BaseError>
pub fn database_named( &self, id: &DatasourceId, ) -> Result<&AnyDatabase, BaseError>
按逻辑名获取数据库容器。
Sourcepub fn datasources(&self) -> Result<&DatasourceRegistry, BaseError>
pub fn datasources(&self) -> Result<&DatasourceRegistry, BaseError>
返回全部具名数据源。
Sourcepub fn mysql(&self) -> Result<&Database, BaseError>
pub fn mysql(&self) -> Result<&Database, BaseError>
获取默认数据源的 MySQL 连接池;默认源不是 MySQL 时返回
BaseError::DatabaseNotInitialized。
Sourcepub fn pool_status(&self) -> Option<PoolStatus>
pub fn pool_status(&self) -> Option<PoolStatus>
返回默认数据源的连接池状态快照;未配置数据库时为 None。
不检查生命周期状态,便于关闭后继续观察连接池回收情况。
Sourcepub fn pool_statuses(&self) -> Vec<DatasourcePoolStatus>
pub fn pool_statuses(&self) -> Vec<DatasourcePoolStatus>
返回全部数据源的连接池状态快照。
Sourcepub async fn datasource_health(&self) -> Vec<DatasourceHealth>
pub async fn datasource_health(&self) -> Vec<DatasourceHealth>
返回全部数据源的健康快照。
Sourcepub fn cache(&self) -> Result<&RedisClient, BaseError>
pub fn cache(&self) -> Result<&RedisClient, BaseError>
获取 Redis 客户端;未配置或生命周期已结束时失败。
Sourcepub fn token(&self) -> Result<&TokenManager, BaseError>
pub fn token(&self) -> Result<&TokenManager, BaseError>
获取 Token 管理器;未配置或生命周期已结束时失败。
Sourcepub fn http(&self) -> Result<&HttpClient, BaseError>
pub fn http(&self) -> Result<&HttpClient, BaseError>
获取 HTTP 客户端;未配置或生命周期已结束时失败。
reqwest 客户端无需显式关闭,故该槽位不参与 close/health_check 流程。
Sourcepub fn regex_cache(&self) -> &RegexCache
pub fn regex_cache(&self) -> &RegexCache
获取共享的有界正则缓存。
缓存为冻结的不可变资源,无需参与 close/health_check 流程;始终可用。
Sourcepub async fn health_check(&self) -> ToolsHealth
pub async fn health_check(&self) -> ToolsHealth
检查所有已配置核心资源并返回稳定快照。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tools
impl !RefUnwindSafe for Tools
impl !UnwindSafe for Tools
impl Forget for Tools
impl Move for Tools
impl Send for Tools
impl Sync for Tools
impl Unpin for Tools
impl UnsafeUnpin for Tools
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