pub struct Runtime {
pub executors: Executors,
/* private fields */
}Fields§
§executors: ExecutorsImplementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(
config: Config,
credentials: Vec<Credential>,
executors: Executors,
) -> Self
pub fn new( config: Config, credentials: Vec<Credential>, executors: Executors, ) -> Self
The scheduler policy is derived from the config (routing plus the OAuth
provider rules), as on every publish.
Sourcepub fn usage_queue(&self) -> &UsageQueue
pub fn usage_queue(&self) -> &UsageQueue
The usage queue: the request path calls enqueue with one serialized Go
queuedUsageDetail per upstream request when accepts() (additive API).
Sourcepub fn set_local_model(&self, on: bool)
pub fn set_local_model(&self, on: bool)
Records --local-model (Go modelCatalogUpdaterPlan’s localModel): remote
model catalog updaters must not start when set (additive API).
Sourcepub fn set_cooldown_backend(&self, backend: Arc<dyn Backend>)
pub fn set_cooldown_backend(&self, backend: Arc<dyn Backend>)
Persists cooldowns to backend instead of .cds files (PGSTORE’s cooldown
table; additive API). Call before serving.
Sourcepub fn local_model(&self) -> bool
pub fn local_model(&self) -> bool
Whether --local-model was given.
Sourcepub fn with_plugin_host(self, host: Host) -> Self
pub fn with_plugin_host(self, host: Host) -> Self
Serves with host, a plugin host that already runs (Go hands the host that
registered plugin command-line flags to the service; additive API). Call before
crate::plugins::start.
Sourcepub fn plugins(&self) -> &Host
pub fn plugins(&self) -> &Host
The plugin host (additive API). crate::plugins::start syncs it with the
config.
Sourcepub fn subscribe_config(&self) -> Receiver<()>
pub fn subscribe_config(&self) -> Receiver<()>
Resolves after the next config publish.
Sourcepub fn publish_config(&self, config: Config) -> bool
pub fn publish_config(&self, config: Config) -> bool
Replaces the config and the scheduler policy derived from it. Requests already
running keep their snapshot. False when the config was rejected and nothing
changed (Runtime::accepts_config).
Sourcepub fn publish_config_and_policy(&self, config: Config, policy: Policy) -> bool
pub fn publish_config_and_policy(&self, config: Config, policy: Policy) -> bool
Integration should use this when publishing parsed routing settings too. False when the config was rejected and nothing changed.
Sourcepub fn request_snapshot(&self) -> (Arc<Config>, Arc<Policy>)
pub fn request_snapshot(&self) -> (Arc<Config>, Arc<Policy>)
A coherent config/policy pair for the entire route attempt loop.
pub fn store(&self) -> &Arc<CredentialStore> ⓘ
Sourcepub fn next_pool_offset(&self, key: &str, size: usize) -> usize
pub fn next_pool_offset(&self, key: &str, size: usize) -> usize
Go nextModelPoolOffset: the start index for the next pass over a pool.
Sourcepub fn suspension(&self, credential_id: &str, model: &str) -> Suspension
pub fn suspension(&self, credential_id: &str, model: &str) -> Suspension
One credential’s projected state for one registered model (Go
clientModelProjectionForAuth), for listings and auto.
Sourcepub fn set_oauth_callback_sink(&self, sink: Option<OAuthCallbackSink>)
pub fn set_oauth_callback_sink(&self, sink: Option<OAuthCallbackSink>)
Wires OAuth callback delivery (management owns pending login sessions).
pub fn deliver_oauth_callback(&self, callback: &OAuthCallback) -> OAuthDelivery
Sourcepub fn registry(&self) -> Arc<Registry> ⓘ
pub fn registry(&self) -> Arc<Registry> ⓘ
The model registry for the current config and credential set. Rebuilt only when either changed, so it is always derived, never separately maintained.
pub fn policy(&self) -> Arc<Policy> ⓘ
pub fn publish_policy(&self, policy: Policy)
Sourcepub async fn acquire(
&self,
selection: Selection,
cfg: &Config,
policy: Arc<Policy>,
registry: &Registry,
) -> Result<Lease, AcquireError>
pub async fn acquire( &self, selection: Selection, cfg: &Config, policy: Arc<Policy>, registry: &Registry, ) -> Result<Lease, AcquireError>
Selects a credential that registered the route model. Waits for preparation only
when the executor reports Readiness::PrepareNow (single-flighted per
credential); token refreshes stay with the background loop. The returned lease
holds the committed snapshot.
Sourcepub fn remote_dispatch(&self) -> Option<Arc<dyn RemoteDispatch>>
pub fn remote_dispatch(&self) -> Option<Arc<dyn RemoteDispatch>>
The installed remote dispatcher (Go Home mode), if any.
Sourcepub fn set_remote_dispatch(&self, dispatch: Option<Arc<dyn RemoteDispatch>>)
pub fn set_remote_dispatch(&self, dispatch: Option<Arc<dyn RemoteDispatch>>)
Routes every request through dispatch (Go Home mode) or back to the local
scheduler with None (additive API).
Sourcepub async fn shutdown_codex_refreshes(&self)
pub async fn shutdown_codex_refreshes(&self)
At shutdown: Codex refreshes still waiting for a credential file’s lock (another process holds it) give up, and those that hold it finish, so new tokens a grant returned are written before the process exits. Later refreshes fail.
Go tryRefreshAfterUnauthorized: after an upstream 401 on a credential whose
executor reports a refresh credential, prepare it once (due or not) and return the
committed replacement to retry with.
Sourcepub fn start_auto_refresh(self: &Arc<Self>)
pub fn start_auto_refresh(self: &Arc<Self>)
One replaceable refresh loop. Uses the same preparation lock and atomic revision-checked commit as request acquisition; executors never persist files. ponytail: needs_prepare controls eligibility. Unauthorized lifecycle gating and end-to-end token rotation await executor/lifecycle integration (M4-0027).
pub fn stop_auto_refresh(&self)
Source§impl Runtime
impl Runtime
Sourcepub async fn refresh_credential(
&self,
id: &str,
) -> Result<Arc<Credential>, ExecError>
pub async fn refresh_credential( &self, id: &str, ) -> Result<Arc<Credential>, ExecError>
Runs the executor’s single-flighted preparation now, due or not (management
refresh, Go RefreshAuthFile). Returns the committed credential.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl !UnwindSafe for Runtime
impl Forget for Runtime
impl Move for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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