Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime {
    pub executors: Executors,
    /* private fields */
}

Fields§

§executors: Executors

Implementations§

Source§

impl Runtime

Source

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.

Source

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).

Source

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).

Source

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.

Source

pub fn local_model(&self) -> bool

Whether --local-model was given.

Source

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.

Source

pub fn plugins(&self) -> &Host

The plugin host (additive API). crate::plugins::start syncs it with the config.

Source

pub fn config(&self) -> Arc<Config> ⓘ

The config snapshot to use for one whole request.

Source

pub fn subscribe_config(&self) -> Receiver<()>

Resolves after the next config publish.

Source

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).

Source

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.

Source

pub fn request_snapshot(&self) -> (Arc<Config>, Arc<Policy>)

A coherent config/policy pair for the entire route attempt loop.

Source

pub fn store(&self) -> &Arc<CredentialStore> ⓘ

Source

pub fn next_pool_offset(&self, key: &str, size: usize) -> usize

Go nextModelPoolOffset: the start index for the next pass over a pool.

Source

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.

Source

pub fn set_oauth_callback_sink(&self, sink: Option<OAuthCallbackSink>)

Wires OAuth callback delivery (management owns pending login sessions).

Source

pub fn deliver_oauth_callback(&self, callback: &OAuthCallback) -> OAuthDelivery

Source

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.

Source

pub fn policy(&self) -> Arc<Policy> ⓘ

Source

pub fn publish_policy(&self, policy: Policy)

Source

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.

Source

pub fn remote_dispatch(&self) -> Option<Arc<dyn RemoteDispatch>>

The installed remote dispatcher (Go Home mode), if any.

Source

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).

Source

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.

Source

pub async fn refresh_after_unauthorized( &self, credential: &Credential, cfg: &Config, ) -> Option<Arc<Credential>>

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.

Source

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).

Source

pub fn stop_auto_refresh(&self)

Source§

impl Runtime

Source

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§

Source§

impl Drop for Runtime

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more