pub struct SelectionRequest<'a> {Show 14 fields
pub provider: OAuthProviderId,
pub model: Option<&'a str>,
pub now_ms: u64,
pub max_snapshot_age_ms: u64,
pub preference: &'a [String],
pub explicit_account: Option<&'a str>,
pub exclude: &'a [CredentialRef],
pub strategy: Strategy,
pub exhausted_at_percent: f64,
pub current: Option<&'a CredentialRef>,
pub urgent_horizon_ms: u64,
pub sticky: bool,
pub grace: &'a [AccountCapacity],
pub grace_max_age_ms: u64,
}Expand description
A selection request. All times are epoch milliseconds.
Fields§
§provider: OAuthProviderId§model: Option<&'a str>Model the request is for; None = any (model-scoped windows still apply).
now_ms: u64§max_snapshot_age_ms: u64Observations older than this are stale (not capacity).
preference: &'a [String]Operator preference (labels, default for the bare slot).
explicit_account: Option<&'a str>Explicit account label; when set no other account is considered.
exclude: &'a [CredentialRef]Accounts that must not be selected (e.g. a seat that just failed).
strategy: Strategy§exhausted_at_percent: f64Utilization percent at/above which a window counts as exhausted.
current: Option<&'a CredentialRef>The seat currently pinned for this provider, if any. Only consulted
when sticky is set under Strategy::SoonestReset;
it never bypasses eligibility or exclusion.
urgent_horizon_ms: u64An anchored budget window resetting within this many ms of now_ms
is urgent (tier 1). Default DEFAULT_URGENT_HORIZON_MS.
sticky: boolKeep current when it is still eligible unless a
candidate sits in a strictly higher tier (or both are tier 1 and the
candidate resets strictly sooner). Avoids seat thrash and prompt-cache
loss. Applies to Strategy::SoonestReset only; false in
new so other strategies are unaffected.
grace: &'a [AccountCapacity]Last successful readings for accounts whose current usage read
failed transiently (usage-endpoint 429, 5xx, timeout, transport).
Such an account (observation QuotaObservation::Unknown) is
evaluated on its reading here instead: strictly younger than
grace_max_age_ms, never past an exhausted
window, an exclusion or a cooldown. Graced seats rank after every
fresh one, but a graced sticky seat stays (a read failure alone is no
reason to switch: the sticky rule judges the graced reading exactly
as it would a fresh one). Empty in new.
grace_max_age_ms: u64Oldest graced reading that still counts. Default
USAGE_READ_GRACE.
Implementations§
Source§impl<'a> SelectionRequest<'a>
impl<'a> SelectionRequest<'a>
Sourcepub fn new(
provider: OAuthProviderId,
now_ms: u64,
max_snapshot_age_ms: u64,
) -> SelectionRequest<'a>
pub fn new( provider: OAuthProviderId, now_ms: u64, max_snapshot_age_ms: u64, ) -> SelectionRequest<'a>
Minimal request with defaults: any model, no preference/exclusions, lowest-utilization strategy, 100 % exhaustion threshold, no current seat, default urgent horizon, not sticky.
Sourcepub fn soonest_reset(
provider: OAuthProviderId,
now_ms: u64,
max_snapshot_age_ms: u64,
) -> SelectionRequest<'a>
pub fn soonest_reset( provider: OAuthProviderId, now_ms: u64, max_snapshot_age_ms: u64, ) -> SelectionRequest<'a>
Like new but with Strategy::SoonestReset, sticky
selection and the default urgent horizon. Set
current for stickiness to have any effect.
Trait Implementations§
Source§impl<'a> Clone for SelectionRequest<'a>
impl<'a> Clone for SelectionRequest<'a>
Source§fn clone(&self) -> SelectionRequest<'a>
fn clone(&self) -> SelectionRequest<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for SelectionRequest<'a>
impl<'a> RefUnwindSafe for SelectionRequest<'a>
impl<'a> Send for SelectionRequest<'a>
impl<'a> Sync for SelectionRequest<'a>
impl<'a> Unpin for SelectionRequest<'a>
impl<'a> UnsafeUnpin for SelectionRequest<'a>
impl<'a> UnwindSafe for SelectionRequest<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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