Poll loop: interval floor, per-repo jitter, quiet window #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #1. Depends on: PgStore JobStore impl, Gitea client
Goal
Give
tireless-worker pollan actual loop. Today it logs one line and waits forSIGTERM.
For each enabled tracked repo whose interval has elapsed, list opted-in issues,
enqueue what is new, and store the returned ETag. The loop must respect the
interval floor, apply per-repo jitter so N repos do not fire together, and skip
everything during a configured quiet window.
Config::poll.clamp()already applies the floor; use it rather than comparingintervals by hand.
Files
crates/tireless-worker/src/main.rs— wire the poll role to a loopcrates/tireless-worker/src/poll.rs— new; the loop itselfcrates/tireless-core/src/config.rs— a quiet-window predicate, if it iscleaner to test there than in the worker
Steps
pollmodule with a loop that ticks, selects due repos, and sleepsuntil the next due time rather than spinning on a fixed short interval.
Poll::clampto each repo's requested interval, and add jitter up topoll.jitter_seconds, derived from the repo id so it is stable per reporather than re-randomised every tick.
HH:MMinlocal time;
Config::validatealready guarantees both ends are present orneither.
JobStore::enqueueand persist the new ETag andlast_polled_at.loop an operator watches to decide whether the thing is working.
Acceptance
cargo test --workspacecargo clippy --all-targets --all-features -- -D warningsmin_interval_secondsispolled at the floor, not at the requested rate.
between repos.
outside it, including a window that wraps midnight.
Out of scope
Make the clock injectable instead if the tests need it.