pub struct RepublishScheduler { /* private fields */ }Expand description
Republish-scheduler handle. Owns the per-hash heap and the abort signal so the runtime can stop it on shutdown.
§The authoritative-due invariant
A BinaryHeap cannot remove or reschedule an interior entry, so any
rescheduling leaves the old entry behind as a tombstone. scheduled is
therefore the authority: it maps each live hash to the ONE due_us that
counts, and drain_cycle discards a popped entry whose due_us
disagrees. Without that check a tombstone is resurrected the moment its
hash is scheduled again — it pops already-overdue, passes a
membership-only test, and buys a spurious republish. Two call patterns hit
that: a re-seed racing the tick path’s drain-then-reschedule, and
Self::unschedule followed by a later re-seed.
Implementations§
Source§impl RepublishScheduler
impl RepublishScheduler
Sourcepub fn schedule_steady(&self, hash: ContentHash)
pub fn schedule_steady(&self, hash: ContentHash)
Schedule hash with the steady-state jitter window (30–50 min),
superseding any due time it already has.
A fresh draw per cycle is ADR 022 §STORE Flow step 3. Superseding is
safe because the displaced heap entry no longer matches the
authoritative due time and drain_cycle discards it.
Sourcepub fn schedule_steady_if_absent(&self, hash: ContentHash) -> bool
pub fn schedule_steady_if_absent(&self, hash: ContentHash) -> bool
Schedule hash with the steady-state jitter window (30–50 min) only if
it has no live entry. Returns whether it was added.
The cache-event path uses this so that a repeated event (a ranged fill announces once per completed block) keeps the due time the hash already has rather than pushing it back.
Sourcepub fn mark_announced(&self, hash: ContentHash)
pub fn mark_announced(&self, hash: ContentHash)
Record that a peer accepted a Store with non-empty coverage for hash.
Sourcepub fn is_announced(&self, hash: &ContentHash) -> bool
pub fn is_announced(&self, hash: &ContentHash) -> bool
Whether a peer accepted a Store with non-empty coverage for hash
since it was last unscheduled.
Sourcepub fn seed_cold_start<I>(&self, iter: I) -> usizewhere
I: IntoIterator<Item = ContentHash>,
pub fn seed_cold_start<I>(&self, iter: I) -> usizewhere
I: IntoIterator<Item = ContentHash>,
Batch-schedule every hash in iter with an independent
cold-start jitter draw (uniform(0, 40 min) per hash, NOT a
shared timestamp). Callers pass a holder_snapshot result,
or origin_held_snapshot for the origin-only rescan — never
access_times_snapshot, which is eviction-recency state rather
than the on-disk set; see the iter_hashes rustdoc.
Seeding leaves an already-scheduled hash alone: it keeps its existing
due time rather than being pulled earlier by a re-seed. The lag sweep
in run_republish and the periodic origin rescan both run against a
populated scheduler, so without this a burst of re-seeds would keep
dragging every due time toward the present.
Returns the number of hashes newly scheduled — useful for the startup log line so operators can see how big the cold-start queue is, and for the sweep so a no-op sweep is distinguishable from a repair.
Sourcepub fn unschedule(&self, hash: &ContentHash)
pub fn unschedule(&self, hash: &ContentHash)
Unschedule hash — used when the cache evicts the blob, or holds no
whole block of it. Clears its announced mark, so the next cache event
for it publishes eagerly again.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RepublishScheduler
impl RefUnwindSafe for RepublishScheduler
impl Send for RepublishScheduler
impl Sync for RepublishScheduler
impl Unpin for RepublishScheduler
impl UnsafeUnpin for RepublishScheduler
impl UnwindSafe for RepublishScheduler
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request