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
impl PollSchedule
pub const fn new(interval: RefreshInterval) -> Self
Sourcepub fn with_idle(self, idle: Duration) -> Self
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.
Sourcepub fn set_intervals(&mut self, interval: RefreshInterval, idle: Duration)
pub fn set_intervals(&mut self, interval: RefreshInterval, idle: Duration)
Change both intervals while running.
pub const fn interval(&self) -> RefreshInterval
Sourcepub const fn idle_floor() -> Duration
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.
Sourcepub const fn consecutive_offline(&self) -> u32
pub const fn consecutive_offline(&self) -> u32
The unbroken run of offline polls this schedule has seen.
Sourcepub fn offline_for(&self, now: Timestamp) -> Option<Duration>
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.
Sourcepub fn next_poll(
&mut self,
failure: Option<&RefreshState>,
now: Timestamp,
jitter: &dyn Jitter,
) -> NextPoll
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.
Sourcepub fn next_poll_with(
&mut self,
failure: Option<&RefreshState>,
conditions: PollConditions,
now: Timestamp,
jitter: &dyn Jitter,
) -> NextPoll
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
- Stretched, when the account’s remaining quota is under
LOW_PRIMARY_REMAINING_PERCENT: the active interval timesPrimaryPressure::stretch_factor(2, or 4 underCRITICAL_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: a304is free, but the poll that finds new work is not, and every host on the account draws from the same bucket. - Idle, when the pass was quiet.
- Nominal, the active interval, otherwise.