Skip to main content

PollSchedule

Struct PollSchedule 

Source
pub struct PollSchedule { /* private fields */ }
Expand description

The bounded, budget-aware poll interval.

§The floor is a rate-budget constraint, not a preference

RefreshInterval refuses anything under 30 seconds at construction, and every delay this type produces is at least that — including the ones it computes from a remote header. A rate limit may only ever make this loop slower.

§retry_delay is an absolute floor, not an addend

c3 documents RefreshState::retry_delay as “the earliest time a retry may occur”: the scheduling rule is next_attempt_at = now + retry_delay, and not the ordinary interval plus it. Adding the two compounds on every successive retry — each new answer carries the remaining window, so an addend ratchets outward — and the symptom is a dashboard that stays dark long after GitHub said it could come back, which reads as a hang rather than as a rate limit. So the two are combined with max, which is what makes the floor a floor.

Implementations§

Source§

impl PollSchedule

Source

pub const fn new(interval: RefreshInterval) -> Self

Source

pub fn with_idle(self, idle: Duration) -> Self

Poll a quiet target every idle instead of every active interval.

Never longer than the active interval: an idle interval above it would make a quiet target slower to notice work than a busy one.

Source

pub fn set_intervals(&mut self, interval: RefreshInterval, idle: Duration)

Change both intervals while running.

Source

pub const fn interval(&self) -> RefreshInterval

Source

pub const fn idle(&self) -> Duration

The interval a quiet target is polled at.

Source

pub const fn idle_floor() -> Duration

The shortest delay this schedule ever produces: the idle interval’s floor. See IdlePollInterval for why it is lower than Self::floor.

Source

pub const fn nominal(&self) -> Duration

The nominal interval as a Duration.

Source

pub const fn consecutive_offline(&self) -> u32

The unbroken run of offline polls this schedule has seen.

Source

pub fn offline_for(&self, now: Timestamp) -> Option<Duration>

How long GitHub has been unreachable, or None when it is not.

Measured from the first poll of the current run rather than inferred from Self::consecutive_offline times the interval. The two diverge as soon as the back-off starts doubling, and this is the number the 24-hour queue-cancellation warning is compared against — an estimate would make that warning fire early or late, and it is the one thing the offline state exists to say.

Source

pub const fn floor() -> Duration

The hard floor no computed delay may go below.

Source

pub fn next_poll( &mut self, failure: Option<&RefreshState>, now: Timestamp, jitter: &dyn Jitter, ) -> NextPoll

Decide when to poll next, given how this pass ended.

failure is the most severe failure across the targets polled this pass, or None when every target answered. A pass that answered resets the offline run, which is the whole of “recovery needs no bookkeeping”: demand is recomputed from the current queued-run set on every poll, so there is nothing else to unwind.

Source

pub fn next_poll_with( &mut self, failure: Option<&RefreshState>, conditions: PollConditions, now: Timestamp, jitter: &dyn Jitter, ) -> NextPoll

Self::next_poll, with what a successful pass found.

§On success, three paces, in this order
  1. Stretched, when the account’s remaining quota is under LOW_PRIMARY_REMAINING_PERCENT: the active interval times PrimaryPressure::stretch_factor (2, or 4 under CRITICAL_PRIMARY_REMAINING_PERCENT), but never past the quota’s reset — waiting longer than that buys nothing, because the bucket is full again. This wins over idle: a 304 is free, but the poll that finds new work is not, and every host on the account draws from the same bucket.
  2. Idle, when the pass was quiet.
  3. Nominal, the active interval, otherwise.

Trait Implementations§

Source§

impl Clone for PollSchedule

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 PollSchedule

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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