pub struct Host { /* private fields */ }Expand description
The plugin host. Cheap to clone.
Implementations§
Source§impl Host
impl Host
Sourcepub fn host_config_summary(&self) -> HostConfigSummary
pub fn host_config_summary(&self) -> HostConfigSummary
Go hostConfigSummary.
Sourcepub fn auth_provider_identifiers(&self) -> Vec<String>
pub fn auth_provider_identifiers(&self) -> Vec<String>
Go AuthProviderIdentifiers.
Sourcepub fn auth_provider_record(&self, provider: &str) -> Option<Record>
pub fn auth_provider_record(&self, provider: &str) -> Option<Record>
Go authProviderRecord: the first active auth provider for provider.
Sourcepub fn has_auth_provider(&self, provider: &str) -> bool
pub fn has_auth_provider(&self, provider: &str) -> bool
Go HasAuthProvider.
Sourcepub fn parse_auths(&self, req: AuthParseRequest) -> ParseAuthsResult
pub fn parse_auths(&self, req: AuthParseRequest) -> ParseAuthsResult
Go ParseAuths. With a provider, only that provider’s plugin is asked; otherwise
every auth provider in order until one handles the material or fails. Blocking:
credential loading is synchronous, as Go’s synthesizer is.
Sourcepub async fn start_login(
&self,
provider: &str,
base_url: &str,
metadata: Metadata,
scope: &RequestScope,
) -> Result<Option<AuthLoginStartResponse>, CallError>
pub async fn start_login( &self, provider: &str, base_url: &str, metadata: Metadata, scope: &RequestScope, ) -> Result<Option<AuthLoginStartResponse>, CallError>
Go StartLogin: Ok(None) when no plugin owns provider.
Sourcepub async fn poll_login(
&self,
provider: &str,
state: &str,
metadata: Metadata,
scope: &RequestScope,
) -> Result<Option<AuthLoginPollResponse>, CallError>
pub async fn poll_login( &self, provider: &str, state: &str, metadata: Metadata, scope: &RequestScope, ) -> Result<Option<AuthLoginPollResponse>, CallError>
Go PollLogin.
Sourcepub async fn refresh_auth(
&self,
auth: &AuthView,
scope: &RequestScope,
) -> Result<Option<PluginAuth>, CallError>
pub async fn refresh_auth( &self, auth: &AuthView, scope: &RequestScope, ) -> Result<Option<PluginAuth>, CallError>
Go RefreshAuth: Ok(None) when no plugin owns the credential’s provider.
Sourcepub async fn frontend_auth_providers(
&self,
) -> (Vec<(String, String)>, Option<String>)
pub async fn frontend_auth_providers( &self, ) -> (Vec<(String, String)>, Option<String>)
Go RegisterFrontendAuthProviders: (access provider key, plugin ID) for each
active frontend auth provider in order, and the exclusive key (highest priority,
then lowest ID) if any. Keys are plugin:<id>:<identifier>; identifiers are asked
on every call, as Go does.
Sourcepub async fn frontend_auth_identifier(&self, plugin_id: &str) -> Option<String>
pub async fn frontend_auth_identifier(&self, plugin_id: &str) -> Option<String>
Go accessAdapter.Identifier for a plugin: plugin:<id>:<identifier>, asking the
plugin each time. None when the plugin is gone or answers empty.
Sourcepub async fn frontend_authenticate(
&self,
plugin_id: &str,
req: &FrontendAuthRequest,
) -> Option<FrontendAuthOutcome>
pub async fn frontend_authenticate( &self, plugin_id: &str, req: &FrontendAuthRequest, ) -> Option<FrontendAuthOutcome>
Go accessAdapter.Authenticate: None is “not handled” (unavailable plugin, RPC
failure, or not authenticated); the caller tries the next provider.
Source§impl Host
impl Host
Sourcepub fn auth_parser(&self) -> Arc<dyn PluginAuthParser> ⓘ
pub fn auth_parser(&self) -> Arc<dyn PluginAuthParser> ⓘ
This host as Go’s PluginAuthParser for credential loading
(RegisterPluginAuthParser(pluginHost)), held weakly. From then on, this host
keeps cpa-core’s auth-parser flag current, so without an auth provider loading
skips the parser after one atomic load.
Source§impl Host
impl Host
Sourcepub async fn register_command_line_flags(
&self,
builtin: &dyn Fn(&str) -> bool,
) -> Vec<CliFlag>
pub async fn register_command_line_flags( &self, builtin: &dyn Fn(&str) -> bool, ) -> Vec<CliFlag>
Go RegisterCommandLineFlags: asks every active command-line plugin for its flags
and keeps valid ones that clash neither with a built-in flag (builtin) nor with a
higher-priority plugin. Returns the flags accepted now.
Sourcepub fn command_line_flag(&self, name: &str) -> Option<CliFlag>
pub fn command_line_flag(&self, name: &str) -> Option<CliFlag>
A registered plugin flag.
Sourcepub fn set_command_line_flag(&self, name: &str, raw: &str) -> Result<(), String>
pub fn set_command_line_flag(&self, name: &str, raw: &str) -> Result<(), String>
Go commandLineFlagValue.Set.
Sourcepub fn has_triggered_command_line_flags(&self) -> bool
pub fn has_triggered_command_line_flags(&self) -> bool
Go HasTriggeredCommandLineFlags.
Sourcepub async fn execute_command_line(
&self,
program: &str,
args: &[String],
config_path: &str,
builtin: &[(String, String)],
persist: &dyn Fn(PluginAuth) -> Result<String, String>,
) -> (i32, bool, Vec<Output>)
pub async fn execute_command_line( &self, program: &str, args: &[String], config_path: &str, builtin: &[(String, String)], persist: &dyn Fn(PluginAuth) -> Result<String, String>, ) -> (i32, bool, Vec<Output>)
Go ExecuteCommandLine. builtin lists the host’s own flags as
(name, current value); persist saves an auth a command produced and
returns its path. Returns the exit code, whether any plugin ran, and the output to
write in order.
Source§impl Host
impl Host
Sourcepub async fn executor_provider(&self, record: &Record) -> Option<String>
pub async fn executor_provider(&self, record: &Record) -> Option<String>
Go executorProvider: the provider the plugin registered models for, else its
executor.identifier, lowercased.
Sourcepub async fn executor_adapter(&self, plugin_id: &str) -> Result<Adapter, String>
pub async fn executor_adapter(&self, plugin_id: &str) -> Result<Adapter, String>
Go executorAdapterForPlugin.
Sourcepub async fn executor_plugin_ready(
&self,
plugin_id: &str,
source_format: &str,
) -> bool
pub async fn executor_plugin_ready( &self, plugin_id: &str, source_format: &str, ) -> bool
Go executorPluginReady: an active, unfused executor plugin that serves static
models and can take a request in source_format.
Sourcepub async fn executor_execute(
&self,
adapter: &Adapter,
req: &ExecutorRequest,
scope: &RequestScope,
) -> Result<ExecutorResponse, CallError>
pub async fn executor_execute( &self, adapter: &Adapter, req: &ExecutorRequest, scope: &RequestScope, ) -> Result<ExecutorResponse, CallError>
executor.execute with a callback context.
Sourcepub async fn executor_count_tokens(
&self,
adapter: &Adapter,
req: &ExecutorRequest,
scope: &RequestScope,
) -> Result<ExecutorResponse, CallError>
pub async fn executor_count_tokens( &self, adapter: &Adapter, req: &ExecutorRequest, scope: &RequestScope, ) -> Result<ExecutorResponse, CallError>
executor.count_tokens with a callback context.
Sourcepub async fn executor_http_request(
&self,
adapter: &Adapter,
req: &ExecutorHttpRequest,
scope: &RequestScope,
) -> Result<ExecutorHttpResponse, CallError>
pub async fn executor_http_request( &self, adapter: &Adapter, req: &ExecutorHttpRequest, scope: &RequestScope, ) -> Result<ExecutorHttpResponse, CallError>
executor.http_request with a callback context.
Sourcepub async fn executor_execute_stream(
&self,
adapter: &Adapter,
req: &ExecutorRequest,
scope: &RequestScope,
) -> Result<PluginStream, CallError>
pub async fn executor_execute_stream( &self, adapter: &Adapter, req: &ExecutorRequest, scope: &RequestScope, ) -> Result<PluginStream, CallError>
Go rpcPluginAdapter.ExecuteStream: opens a host stream and a callback context,
sends stream_id and host_callback_id. Inline chunks in the answer are the whole
stream; otherwise chunks arrive through host.stream.emit until the plugin closes
the stream, and the callback context stays open until then.
Source§impl Host
impl Host
pub fn new() -> Self
pub fn with_loader(loader: Arc<dyn Loader>) -> Self
pub fn snapshot(&self) -> Arc<Snapshot> ⓘ
Sourcepub fn active_records(&self) -> Vec<Record>
pub fn active_records(&self) -> Vec<Record>
Records still current: a record whose plugin was unloaded or replaced since the
snapshot was taken is skipped (Go activeRecordsFromSnapshot).
Sourcepub fn current_records(&self, snapshot: &Snapshot) -> Vec<Record>
pub fn current_records(&self, snapshot: &Snapshot) -> Vec<Record>
Go activeRecordsFromSnapshot: the snapshot’s records that are still current.
Sourcepub fn live(&self, record: &Record) -> bool
pub fn live(&self, record: &Record) -> bool
Whether a record may be called right now: not fused and still current. Go checks this at every call, after earlier plugins in the same loop have run.
Sourcepub fn record_current(&self, record: &Record) -> bool
pub fn record_current(&self, record: &Record) -> bool
Go recordCurrent / pluginIdentityCurrent.
pub fn is_fused(&self, id: &str) -> bool
Sourcepub fn fuse(&self, id: &str, what: &str, panic: &str)
pub fn fuse(&self, id: &str, what: &str, panic: &str)
Go fusePlugin: a host-side panic while serving the plugin disables it until its
file changes.
Sourcepub fn plugin_loaded(&self, id: &str) -> bool
pub fn plugin_loaded(&self, id: &str) -> bool
Go PluginLoaded: a library for id is still loaded (active or retired).
Sourcepub fn plugin_busy(&self, id: &str) -> bool
pub fn plugin_busy(&self, id: &str) -> bool
Go PluginBusy: loaded or still loading.
Sourcepub fn plugin_registered(&self, id: &str) -> bool
pub fn plugin_registered(&self, id: &str) -> bool
Go PluginRegistered: active in the current snapshot.
Sourcepub fn registered_plugins(&self) -> Vec<RegisteredPluginInfo>
pub fn registered_plugins(&self) -> Vec<RegisteredPluginInfo>
Go RegisteredPlugins.
Sourcepub async fn apply_config(&self, cfg: Arc<Config>)
pub async fn apply_config(&self, cfg: Arc<Config>)
Go ApplyConfig.
ponytail: runs to completion on its own task even if the caller stops waiting, so
a dropped future can never strand a half-loaded plugin; Go instead aborts on
context cancellation and rolls the load back. Add cancellation with rollback if
shutdown latency during a slow plugin.register ever matters.
Sourcepub async fn unload_plugin(&self, id: &str, wait: Option<Duration>) -> bool
pub async fn unload_plugin(&self, id: &str, wait: Option<Duration>) -> bool
Go UnloadPluginContext: detach id from the runtime, then close every loaded
instance of it, waiting up to wait for running calls.
Sourcepub async fn unload_plugin_until(
&self,
id: &str,
cancel: &CancellationToken,
) -> bool
pub async fn unload_plugin_until( &self, id: &str, cancel: &CancellationToken, ) -> bool
Go UnloadPluginContext with a cancellable context: cancelling cancel stops
waiting for the apply lock (false) or for the plugin to shut down, and releases
the lock; the shutdown itself still completes on its own thread.
Sourcepub async fn shutdown_all(&self, wait: Option<Duration>)
pub async fn shutdown_all(&self, wait: Option<Duration>)
Go ShutdownAllContext.
Sourcepub fn record(&self, id: &str) -> Option<Record>
pub fn record(&self, id: &str) -> Option<Record>
Looks up an active, unfused record by plugin ID.
Sourcepub async fn call<T: GoJson, R: GoJson>(
&self,
record: &Record,
method: &str,
request: &R,
) -> Result<T, CallError>
pub async fn call<T: GoJson, R: GoJson>( &self, record: &Record, method: &str, request: &R, ) -> Result<T, CallError>
One typed RPC to an active plugin, fusing it on a host-side panic.
Sourcepub async fn call_with_callback<T: GoJson, R: GoStruct>(
&self,
record: &Record,
method: &str,
request: &R,
scope: &RequestScope,
) -> Result<T, CallError>
pub async fn call_with_callback<T: GoJson, R: GoStruct>( &self, record: &Record, method: &str, request: &R, scope: &RequestScope, ) -> Result<T, CallError>
One RPC that lets the plugin call back: opens a callback context for the record’s
instance, sends its ID as host_callback_id, and closes it when the call returns
(Go openHostCallbackContext around adapter calls).
Sourcepub fn call_blocking<T: GoJson, R: GoJson>(
&self,
record: &Record,
method: &str,
request: &R,
) -> Result<T, CallError>
pub fn call_blocking<T: GoJson, R: GoJson>( &self, record: &Record, method: &str, request: &R, ) -> Result<T, CallError>
Host::call for synchronous callers; see GuardedClient::call_blocking.
Sourcepub fn call_with_callback_blocking<T: GoJson, R: GoStruct>(
&self,
record: &Record,
method: &str,
request: &R,
scope: &RequestScope,
) -> Result<T, CallError>
pub fn call_with_callback_blocking<T: GoJson, R: GoStruct>( &self, record: &Record, method: &str, request: &R, scope: &RequestScope, ) -> Result<T, CallError>
Host::call_with_callback for synchronous callers.
Sourcepub fn open_callback(
&self,
record: &Record,
scope: &RequestScope,
) -> ContextGuard
pub fn open_callback( &self, record: &Record, scope: &RequestScope, ) -> ContextGuard
Opens a callback context for record’s instance.
Source§impl Host
impl Host
Sourcepub fn set_auth_manager(&self, manager: Option<Arc<dyn AuthManager>>)
pub fn set_auth_manager(&self, manager: Option<Arc<dyn AuthManager>>)
Go SetAuthManager.
Source§impl Host
impl Host
pub fn set_model_executor(&self, executor: Option<Arc<dyn ModelExecutor>>)
Source§impl Host
impl Host
Sourcepub async fn intercept_request_before_auth(
&self,
req: RequestInterceptRequest,
skip: &str,
scope: &RequestScope,
) -> RequestInterceptResponse
pub async fn intercept_request_before_auth( &self, req: RequestInterceptRequest, skip: &str, scope: &RequestScope, ) -> RequestInterceptResponse
Go InterceptRequestBeforeAuth[Except].
Sourcepub async fn intercept_request_after_auth(
&self,
req: RequestInterceptRequest,
skip: &str,
scope: &RequestScope,
) -> RequestInterceptResponse
pub async fn intercept_request_after_auth( &self, req: RequestInterceptRequest, skip: &str, scope: &RequestScope, ) -> RequestInterceptResponse
Go InterceptRequestAfterAuth[Except].
Sourcepub fn complete_request(
&self,
completion: RequestCompletion,
skip: &str,
scope: &RequestScope,
)
pub fn complete_request( &self, completion: RequestCompletion, skip: &str, scope: &RequestScope, )
Go CompleteRequest[Except]: one asynchronous request.complete per lifecycle
plugin; delivery never blocks the response.
Sourcepub async fn intercept_response(
&self,
req: ResponseInterceptRequest,
skip: &str,
scope: &RequestScope,
) -> ResponseInterceptResponse
pub async fn intercept_response( &self, req: ResponseInterceptRequest, skip: &str, scope: &RequestScope, ) -> ResponseInterceptResponse
Go InterceptResponse[Except]: successful non-streaming responses.
Sourcepub async fn intercept_stream_chunk(
&self,
req: StreamChunkInterceptRequest,
skip: &str,
scope: &RequestScope,
) -> StreamChunkInterceptResponse
pub async fn intercept_stream_chunk( &self, req: StreamChunkInterceptRequest, skip: &str, scope: &RequestScope, ) -> StreamChunkInterceptResponse
Go InterceptStreamChunk[Except]. Payload chunks (ChunkIndex >= 0) omit request
bodies for schema 3+ and history for schema 5+; the header-init call always
carries them. A dropped chunk ends the chain.
Sourcepub async fn observe_websocket_response_event(
&self,
event: WebSocketResponseEvent,
skip: &str,
scope: &RequestScope,
)
pub async fn observe_websocket_response_event( &self, event: WebSocketResponseEvent, skip: &str, scope: &RequestScope, )
Go ObserveWebSocketResponseEvent[Except]: synchronous, in order, errors logged.
Sourcepub fn has_request_interceptors(&self) -> bool
pub fn has_request_interceptors(&self) -> bool
Go HasRequestInterceptors.
Sourcepub fn has_stream_interceptors(&self) -> bool
pub fn has_stream_interceptors(&self) -> bool
Go HasStreamInterceptors.
Sourcepub fn has_websocket_response_observers(&self) -> bool
pub fn has_websocket_response_observers(&self) -> bool
Go HasWebSocketResponseObservers.
Sourcepub fn has_response_interceptors(&self) -> bool
pub fn has_response_interceptors(&self) -> bool
Go HasResponseInterceptors equivalent for the handler’s fast path.
Sourcepub fn has_request_lifecycle_plugins(&self) -> bool
pub fn has_request_lifecycle_plugins(&self) -> bool
Go HasRequestLifecyclePlugins equivalent.
Sourcepub fn stream_chunk_payload_includes_request_body(&self) -> bool
pub fn stream_chunk_payload_includes_request_body(&self) -> bool
Go StreamChunkPayloadIncludesRequestBody: some stream interceptor speaks schema < 3.
Sourcepub fn stream_chunk_payload_includes_history(&self) -> bool
pub fn stream_chunk_payload_includes_history(&self) -> bool
Go StreamChunkPayloadIncludesHistory: some stream interceptor speaks schema < 5.
Source§impl Host
impl Host
Sourcepub async fn register_management_routes(&self, reserved: &HashSet<String>)
pub async fn register_management_routes(&self, reserved: &HashSet<String>)
Go RegisterManagementRoutes: asks every active plugin with the capability for its
routes and rebuilds both tables. reserved holds built-in METHOD /path keys.
Sourcepub fn management_routes(&self) -> Vec<RouteRecord>
pub fn management_routes(&self) -> Vec<RouteRecord>
Plugin management routes currently registered, by key.
pub fn resource_routes(&self) -> Vec<ResourceRecord>
Sourcepub fn has_management_route(&self, method: &str, path: &str) -> bool
pub fn has_management_route(&self, method: &str, path: &str) -> bool
Whether Self::serve_management would call a plugin for this method and decoded
path (Go checks this before reading the body).
Sourcepub async fn serve_management(&self, req: Inbound) -> Option<Reply>
pub async fn serve_management(&self, req: Inbound) -> Option<Reply>
Go ServeManagementHTTP: None when no plugin route matches.
Sourcepub async fn serve_resource(&self, req: Inbound) -> Option<Reply>
pub async fn serve_resource(&self, req: Inbound) -> Option<Reply>
Go ServeResourceHTTP: GET only, no body forwarded.
Source§impl Host
impl Host
Sourcepub async fn register_models(&self)
pub async fn register_models(&self)
Go v8.0.35 RegisterModels: collects the static models of every model provider or
registrar whose executor scope allows static models. Nothing is published here:
catalog-only models reach the registry only through credentials of their provider
(Self::models_for_provider), executor plugins’ through
Self::register_executors.
Sourcepub async fn models_for_auth(
&self,
auth: &AuthView,
scope: &RequestScope,
) -> AuthModelResult
pub async fn models_for_auth( &self, auth: &AuthView, scope: &RequestScope, ) -> AuthModelResult
Go ModelsForAuth: the first model provider for the credential’s provider (its
auth provider’s identifier, else its registered or executor provider).
Sourcepub async fn register_executors(
&self,
native_provider: &(dyn Fn(&str) -> bool + Sync),
model_providers: &(dyn Fn(&str) -> Vec<String> + Sync),
) -> Option<ExecutorChanges>
pub async fn register_executors( &self, native_provider: &(dyn Fn(&str) -> bool + Sync), model_providers: &(dyn Fn(&str) -> Vec<String> + Sync), ) -> Option<ExecutorChanges>
Go RegisterExecutors. native_provider says whether a built-in executor serves
a provider; model_providers lists the providers registered for a model ID. A
plugin executor claims its provider only when no built-in executor does, and only
models no built-in provider serves; the first plugin (by priority) wins a model
and a provider. None when the plugin set changed meanwhile (Go
commitExecutorState then keeps the previous state).
Sourcepub fn models_for_provider(&self, provider: &str) -> Vec<ModelInfo>
pub fn models_for_provider(&self, provider: &str) -> Vec<ModelInfo>
Go ModelsForProvider.
Sourcepub fn provider_models(&self) -> BTreeMap<String, Vec<ModelInfo>>
pub fn provider_models(&self) -> BTreeMap<String, Vec<ModelInfo>>
Every provider’s plugin models after the last Self::register_executors.
Sourcepub fn executor_providers(&self) -> HashSet<String>
pub fn executor_providers(&self) -> HashSet<String>
The plugin executing provider after the last Self::register_executors.
Sourcepub async fn has_executor_candidate_provider(&self, provider: &str) -> bool
pub async fn has_executor_candidate_provider(&self, provider: &str) -> bool
Go HasExecutorCandidateProvider.
Source§impl Host
impl Host
Sourcepub fn quota_provider_identifiers(&self) -> Vec<String>
pub fn quota_provider_identifiers(&self) -> Vec<String>
Go QuotaProviderIdentifiers.
Sourcepub async fn quota_providers(&self) -> Vec<QuotaProviderInfo>
pub async fn quota_providers(&self) -> Vec<QuotaProviderInfo>
Go QuotaProviders.
Sourcepub async fn quota_provider_plugin_ids(&self) -> HashMap<String, String>
pub async fn quota_provider_plugin_ids(&self) -> HashMap<String, String>
Go QuotaProviderPluginIDs: each provider key to the plugin
Self::quota_provider_record would select for it, with its two-pass
precedence. A plugin fused while describing loses its keys to the next candidate.
Sourcepub async fn quota_provider_record(&self, provider: &str) -> Option<Record>
pub async fn quota_provider_record(&self, provider: &str) -> Option<Record>
Go quotaProviderRecord.
Sourcepub fn quota_provider_record_by_plugin(&self, plugin_id: &str) -> Option<Record>
pub fn quota_provider_record_by_plugin(&self, plugin_id: &str) -> Option<Record>
Go quotaProviderRecordByPlugin.
Sourcepub async fn has_quota_provider(&self, provider: &str) -> bool
pub async fn has_quota_provider(&self, provider: &str) -> bool
Go HasQuotaProvider.
Sourcepub fn has_quota_provider_for_plugin(&self, plugin_id: &str) -> bool
pub fn has_quota_provider_for_plugin(&self, plugin_id: &str) -> bool
Go HasQuotaProviderForPlugin.
Sourcepub async fn describe_quota(
&self,
plugin_id: &str,
) -> Result<Option<QuotaDescribeResponse>, CallError>
pub async fn describe_quota( &self, plugin_id: &str, ) -> Result<Option<QuotaDescribeResponse>, CallError>
Go DescribeQuota: by plugin ID, else by provider.
Sourcepub async fn fetch_quota(
&self,
req: QuotaFetchRequest,
auth: Option<&AuthView>,
scope: &RequestScope,
) -> Result<Option<QuotaFetchResponse>, CallError>
pub async fn fetch_quota( &self, req: QuotaFetchRequest, auth: Option<&AuthView>, scope: &RequestScope, ) -> Result<Option<QuotaFetchResponse>, CallError>
Go FetchQuota: by provider, else by plugin ID. auth is the credential behind
req.auth_index when it resolves (Go authPhysicalJSONByIndex).
Sourcepub async fn fetch_quota_by_plugin(
&self,
plugin_id: &str,
req: QuotaFetchRequest,
auth: Option<&AuthView>,
scope: &RequestScope,
) -> Result<Option<QuotaFetchResponse>, CallError>
pub async fn fetch_quota_by_plugin( &self, plugin_id: &str, req: QuotaFetchRequest, auth: Option<&AuthView>, scope: &RequestScope, ) -> Result<Option<QuotaFetchResponse>, CallError>
Go FetchQuotaByPlugin.
Sourcepub async fn reset_quota(
&self,
req: QuotaResetRequest,
auth: Option<&AuthView>,
scope: &RequestScope,
) -> Result<Option<QuotaResetResponse>, CallError>
pub async fn reset_quota( &self, req: QuotaResetRequest, auth: Option<&AuthView>, scope: &RequestScope, ) -> Result<Option<QuotaResetResponse>, CallError>
Go ResetQuota.
Sourcepub async fn reset_quota_by_plugin(
&self,
plugin_id: &str,
req: QuotaResetRequest,
auth: Option<&AuthView>,
scope: &RequestScope,
) -> Result<Option<QuotaResetResponse>, CallError>
pub async fn reset_quota_by_plugin( &self, plugin_id: &str, req: QuotaResetRequest, auth: Option<&AuthView>, scope: &RequestScope, ) -> Result<Option<QuotaResetResponse>, CallError>
Go ResetQuotaByPlugin.
Source§impl Host
impl Host
Sourcepub fn has_scheduler(&self) -> bool
pub fn has_scheduler(&self) -> bool
Go HasScheduler.
Sourcepub fn scheduler_wants_across_priorities(&self) -> bool
pub fn scheduler_wants_across_priorities(&self) -> bool
Go SchedulerWantsAcrossPriorities.
Sourcepub async fn pick_auth(
&self,
req: SchedulerPickRequest,
) -> Result<Option<SchedulerPickResponse>, CallError>
pub async fn pick_auth( &self, req: SchedulerPickRequest, ) -> Result<Option<SchedulerPickResponse>, CallError>
Go PickAuth: Ok(None) lets the built-in scheduler choose (no scheduler, not
handled, or an invalid answer); Err is the plugin’s RPC failure, which Go
surfaces as a selection error.
Sourcepub fn has_model_routers(&self, skip: &str) -> bool
pub fn has_model_routers(&self, skip: &str) -> bool
Go HasModelRouters[Except].
Sourcepub async fn route_model(
&self,
req: ModelRouteRequest,
skip: &str,
available_providers: &[String],
scope: &RequestScope,
) -> Option<ModelRouteResponse>
pub async fn route_model( &self, req: ModelRouteRequest, skip: &str, available_providers: &[String], scope: &RequestScope, ) -> Option<ModelRouteResponse>
Go RouteModel[Except]: the first router (by priority) that handles the request
with a usable target. available_providers is the providers that currently have
credentials (Go AuthManager.AvailableProviders); a provider target must be one
of them. executor_ready reports whether a plugin executor can take the request
(format negotiation, see crate::executor).
Source§impl Host
impl Host
Sourcepub fn normalize_request(
&self,
from: &str,
to: &str,
model: &str,
body: Bytes,
stream: bool,
) -> Bytes
pub fn normalize_request( &self, from: &str, to: &str, model: &str, body: Bytes, stream: bool, ) -> Bytes
Go NormalizeRequest: every request normalizer, chained.
Sourcepub fn translate_request(
&self,
from: &str,
to: &str,
model: &str,
body: &Bytes,
stream: bool,
) -> Option<Bytes>
pub fn translate_request( &self, from: &str, to: &str, model: &str, body: &Bytes, stream: bool, ) -> Option<Bytes>
Go TranslateRequest: the first translator that answers wins.
Sourcepub fn normalize_response_before(
&self,
t: &ResponseTransform<'_>,
body: Bytes,
) -> Bytes
pub fn normalize_response_before( &self, t: &ResponseTransform<'_>, body: Bytes, ) -> Bytes
Go NormalizeResponseBefore: chained, before native translation.
Sourcepub fn translate_response(
&self,
t: &ResponseTransform<'_>,
body: &Bytes,
) -> Option<Bytes>
pub fn translate_response( &self, t: &ResponseTransform<'_>, body: &Bytes, ) -> Option<Bytes>
Go TranslateResponse: the first translator that answers wins.
Sourcepub fn normalize_response_after(
&self,
t: &ResponseTransform<'_>,
body: Bytes,
) -> Bytes
pub fn normalize_response_after( &self, t: &ResponseTransform<'_>, body: Bytes, ) -> Bytes
Go NormalizeResponseAfter: chained, after translation.
Sourcepub fn has_response_translator(&self) -> bool
pub fn has_response_translator(&self) -> bool
Go hasResponseTranslator.
Sourcepub fn thinking_provider(&self, provider: &str) -> Option<String>
pub fn thinking_provider(&self, provider: &str) -> Option<String>
The plugin that applies thinking for provider, if any.
Sourcepub fn apply_thinking(
&self,
provider: &str,
model: ModelInfo,
config: ThinkingConfig,
body: Bytes,
scope: &RequestScope,
) -> Bytes
pub fn apply_thinking( &self, provider: &str, model: ModelInfo, config: ThinkingConfig, body: Bytes, scope: &RequestScope, ) -> Bytes
Go thinkingAdapter.Apply: the plugin’s body, or body unchanged on any failure.
Sourcepub fn publish_usage(&self, record: UsageRecord)
pub fn publish_usage(&self, record: UsageRecord)
Go usageAdapter.HandleUsage for every usage plugin, in the background. The
caller resolves session fields the way the adapter does (see
usage_session_ids); failures are logged at debug level.
Sourcepub fn has_usage_plugins(&self) -> bool
pub fn has_usage_plugins(&self) -> bool
Whether any usage plugin is active.
Source§impl Host
impl Host
Sourcepub fn translator_hooks(&self) -> Arc<dyn Hooks> ⓘ
pub fn translator_hooks(&self) -> Arc<dyn Hooks> ⓘ
This host as Go’s translator.PluginHooks (sdktranslator.SetPluginHooks(host)).
It holds the host weakly, so installing it process-wide keeps nothing alive.
From then on, this host keeps cpa-translate’s hook flag current, so with no
translator plugin the registry skips the hooks after one atomic load.
Trait Implementations§
Source§impl PluginRuntime for Host
impl PluginRuntime for Host
Source§fn plugin_busy(&self, id: &str) -> bool
fn plugin_busy(&self, id: &str) -> bool
Source§fn unload_plugin<'a>(
&'a self,
id: &'a str,
cancel: &'a CancellationToken,
) -> BoxFuture<'a, bool>
fn unload_plugin<'a>( &'a self, id: &'a str, cancel: &'a CancellationToken, ) -> BoxFuture<'a, bool>
false when nothing was unloaded. Cancelling
cancel stops waiting for it (Go UnloadPluginContext).Source§fn plugin_registered(&self, id: &str) -> bool
fn plugin_registered(&self, id: &str) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for Host
impl !UnwindSafe for Host
impl Freeze for Host
impl Send for Host
impl Sync for Host
impl Unpin for Host
impl UnsafeUnpin for Host
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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