pub struct KnowledgeRuntime { /* private fields */ }Implementations§
Source§impl KnowledgeRuntime
impl KnowledgeRuntime
pub fn new(result_cache_capacity: usize) -> Self
pub fn install_provider<F>( &self, kind: ProviderKind, datasource_id: DatasourceId, build: F, ) -> KnowledgeResult<Generation>
Sourcepub fn install_provider_named<F>(
&self,
name: &str,
kind: ProviderKind,
datasource_id: DatasourceId,
build: F,
is_default: bool,
) -> KnowledgeResult<Generation>
pub fn install_provider_named<F>( &self, name: &str, kind: ProviderKind, datasource_id: DatasourceId, build: F, is_default: bool, ) -> KnowledgeResult<Generation>
安装一个 provider:注册到命名注册表(name -> handle),并在 is_default
时同时设置为默认 provider。共享同一个单调递增 generation 计数器,
保证重载后的结果缓存键不与旧数据冲突。
pub fn configure_result_cache( &self, enabled: bool, capacity: usize, ttl: Duration, )
pub fn configure_redis_cache(&self, global_enabled: bool, capacity: usize)
pub fn current_generation(&self) -> Option<Generation>
pub fn snapshot(&self) -> RuntimeSnapshot
pub fn current_metadata_scope(&self) -> MetadataCacheScope
pub fn current_provider_kind(&self) -> Option<ProviderKind>
Sourcepub fn provider_by_name(
&self,
name: &str,
) -> KnowledgeResult<Arc<ProviderHandle>>
pub fn provider_by_name( &self, name: &str, ) -> KnowledgeResult<Arc<ProviderHandle>>
按名称取 provider handle;未找到时返回错误。
pub fn provider_exists(&self, name: &str) -> bool
pub fn provider_names(&self) -> Vec<String>
Sourcepub fn prune_named_providers_except(&self, keep: &HashSet<String>)
pub fn prune_named_providers_except(&self, keep: &HashSet<String>)
清理命名注册表中不在 keep 内的过期 provider。仅在成功安装后调用,
中途失败时保留旧状态。
Sourcepub fn named_provider_epoch(&self) -> u64
pub fn named_provider_epoch(&self) -> u64
命名 provider 注册表版本号:任何安装/清理都会递增,用于路由 memo 失效判断。
pub fn record_result_cache_hit(&self)
pub fn record_result_cache_miss(&self)
pub fn record_metadata_cache_hit(&self)
pub fn record_metadata_cache_miss(&self)
pub fn record_local_cache_hit(&self)
pub fn record_local_cache_miss(&self)
pub fn execute(&self, req: &QueryRequest) -> KnowledgeResult<QueryResponse>
Sourcepub fn execute_for(
&self,
name: &str,
req: &QueryRequest,
) -> KnowledgeResult<QueryResponse>
pub fn execute_for( &self, name: &str, req: &QueryRequest, ) -> KnowledgeResult<QueryResponse>
对指定命名 provider 执行查询。
pub fn execute_first_row_fields( &self, sql: &str, params: &[DataField], cache_policy: CachePolicy, ) -> KnowledgeResult<RowData>
Sourcepub fn execute_first_row_fields_for(
&self,
name: &str,
sql: &str,
params: &[DataField],
cache_policy: CachePolicy,
) -> KnowledgeResult<RowData>
pub fn execute_first_row_fields_for( &self, name: &str, sql: &str, params: &[DataField], cache_policy: CachePolicy, ) -> KnowledgeResult<RowData>
对指定命名 provider 执行首行查询。
pub async fn execute_async( &self, req: &QueryRequest, ) -> KnowledgeResult<QueryResponse>
pub async fn execute_for_async( &self, name: &str, req: &QueryRequest, ) -> KnowledgeResult<QueryResponse>
pub async fn execute_first_row_fields_async( &self, sql: &str, params: &[DataField], cache_policy: CachePolicy, ) -> KnowledgeResult<RowData>
pub async fn execute_first_row_fields_for_async( &self, name: &str, sql: &str, params: &[DataField], cache_policy: CachePolicy, ) -> KnowledgeResult<RowData>
Auto Trait Implementations§
impl !Freeze for KnowledgeRuntime
impl RefUnwindSafe for KnowledgeRuntime
impl Send for KnowledgeRuntime
impl Sync for KnowledgeRuntime
impl Unpin for KnowledgeRuntime
impl UnsafeUnpin for KnowledgeRuntime
impl UnwindSafe for KnowledgeRuntime
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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