pub struct ToolsBuilder { /* private fields */ }Expand description
仅在启动期可变的应用资源构建器。
Implementations§
Source§impl ToolsBuilder
impl ToolsBuilder
Sourcepub fn database(self, database: AnyDatabase) -> Self
pub fn database(self, database: AnyDatabase) -> Self
设置默认数据源的运行时数据库后端(MySQL 或 PostgreSQL,兼容入口)。
Sourcepub fn database_named(self, id: DatasourceId, database: AnyDatabase) -> Self
pub fn database_named(self, id: DatasourceId, database: AnyDatabase) -> Self
用逻辑名注册一个数据源。
Sourcepub fn database_named_with_policy(
self,
id: DatasourceId,
database: AnyDatabase,
required: bool,
) -> Self
pub fn database_named_with_policy( self, id: DatasourceId, database: AnyDatabase, required: bool, ) -> Self
用逻辑名注册一个数据源,并指定它是否参与 readiness。
Sourcepub fn mysql_named(self, id: DatasourceId, database: Database) -> Self
pub fn mysql_named(self, id: DatasourceId, database: Database) -> Self
用逻辑名注册一个 MySQL 数据源。
Sourcepub fn postgres_named(self, id: DatasourceId, database: Database) -> Self
pub fn postgres_named(self, id: DatasourceId, database: Database) -> Self
用逻辑名注册一个 PostgreSQL 数据源。
Sourcepub fn default_datasource(self, id: DatasourceId) -> Self
pub fn default_datasource(self, id: DatasourceId) -> Self
显式指定默认数据源。
Sourcepub fn cache(self, cache: RedisClient) -> Self
pub fn cache(self, cache: RedisClient) -> Self
设置唯一 Redis 客户端。
Sourcepub async fn cache_from_url(
self,
url: impl Into<String>,
config: RedisConfig,
) -> Result<Self, BaseError>
pub async fn cache_from_url( self, url: impl Into<String>, config: RedisConfig, ) -> Result<Self, BaseError>
从 URL + 池配置连接 Redis 并注册。
失败返回 BaseError::RedisConnectionFailed(保留底层错误链)。
Sourcepub fn token(self, token: TokenManager) -> Self
pub fn token(self, token: TokenManager) -> Self
设置唯一 Token 管理器。
Sourcepub fn http(self, client: HttpClient) -> Self
pub fn http(self, client: HttpClient) -> Self
设置唯一 HTTP 客户端。
reqwest 客户端无需显式关闭,构建后只读共享,不参与 close/health_check 流程。
Sourcepub fn regex_cache(self, cache: RegexCache) -> Self
pub fn regex_cache(self, cache: RegexCache) -> Self
覆盖默认容量的共享正则缓存。
Trait Implementations§
Source§impl Debug for ToolsBuilder
impl Debug for ToolsBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for ToolsBuilder
impl !UnwindSafe for ToolsBuilder
impl Forget for ToolsBuilder
impl Freeze for ToolsBuilder
impl Move for ToolsBuilder
impl Send for ToolsBuilder
impl Sync for ToolsBuilder
impl Unpin for ToolsBuilder
impl UnsafeUnpin for ToolsBuilder
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