Skip to main content

Period

Struct Period 

Source
pub struct Period {
    pub id: u64,
    /* private fields */
}
Expand description

One idle period. Pure: every clock reading is passed in.

Fields§

§id: u64

Implementations§

Source§

impl Period

Source

pub fn start( id: u64, cfg: PeriodConfig, fingerprint: u64, last: &KeepWarmUsage, evidence: TtlEvidence, anchor: CacheAnchor, now: Instant, wall: SystemTime, ) -> Result<Period, PeriodEnd>

Start a period at now (the session just went idle). last is the usage of the turn’s last request; evidence what the session knows about the TTL the server honours.

Source

pub fn start_in_epoch( id: u64, cfg: PeriodConfig, fingerprint: u64, last: &KeepWarmUsage, evidence: TtlEvidence, anchor: CacheAnchor, now: Instant, wall: SystemTime, carry: Option<&EpochCarry>, ) -> Result<Period, PeriodEnd>

start, continuing carry when the cache epoch has not changed since an earlier period (see EpochCarry).

Source

pub fn epoch_carry(&self) -> EpochCarry

What the next period of this cache epoch continues from.

Source

pub fn fingerprint(&self) -> u64

Source

pub fn pings(&self) -> u32

Source

pub fn ledger_usd(&self) -> f64

Source

pub fn bound_usd(&self) -> f64

Source

pub fn worst_next_usd(&self) -> f64

Read-path worst case of the next ping (cache hit, max_tokens of output): what the ski-rental bound checks use, and what an aborted in-flight ping is booked at.

Source

pub fn exposure_next_usd(&self) -> f64

Most the next ping can bill once dispatched, a full cache miss included (≥ worst_next_usd): what the max_session_cost admission check uses.

Source

pub fn prefix_tokens(&self) -> u64

Source

pub fn next_at(&self) -> Instant

Source

pub fn mode(&self) -> CacheKeepWarm

Source

pub fn ttl(&self) -> CacheTtl

The honoured TTL the period is governed by.

Source

pub fn fired_age(&self) -> Duration

Source

pub fn in_flight(&self) -> bool

Source

pub fn set_mode(&mut self, mode: CacheKeepWarm)

/keepwarm auto|<N>h while a period runs: the new window applies.

Source

pub fn deadline(&self, now: Instant, wall: SystemTime) -> Option<Instant>

When the next ping is due: the earlier of the monotonic deadline and the wall-clock deadline mapped onto now (after a suspend the monotonic one is late by the time slept). None while in flight.

Source

pub fn fire( &mut self, now: Instant, wall: SystemTime, session_cost: f64, max_session_cost: Option<f64>, ) -> Fire

The timer fired. Ping marks the ping in flight.

Source

pub fn charge(&mut self, cost_usd: f64)

Book spend that belongs to this period (every ping, failed or not).

Source

pub fn ping_sent( &mut self, usage: &KeepWarmUsage, anchor: Option<CacheAnchor>, downgraded: bool, ) -> Result<(), PeriodEnd>

The in-flight ping was sent and accepted (its cost already charged); anchor is the runtime’s anchor after it, downgraded the session’s silent-downgrade latch. Schedules the next ping or says why the period is over.

Source

pub fn ping_failed( &mut self, failure: &PingFailure, now: Instant, wall: SystemTime, ) -> Result<Duration, PeriodEnd>

The in-flight ping failed (its cost, if any, already charged). Transient failures retry with bounded backoff as long as the retry still lands before expiry.

Trait Implementations§

Source§

impl Clone for Period

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Period

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

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

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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