Added a backfill in 7-day windows, and fetches now keep their data on a failure

Backfilling a long window (an early --since, or a long time offline)
hit the API's rate limit, which could still be exceeded after waiting
once, and then everything fetched so far was lost.

Before each Find a Tender source's worker starts, a start point more
than 7 days ago is now backfilled in 7-day windows bounded on both
sides, oldest first, each saved before the next is fetched. A window
that fails is saved as far as it got and fetched again from its start
after the source's interval. The worker then carries on from the end
of the last window.

A 429 is now waited out up to sources.<source>.rate_limit_retries
times (default 5) rather than once; fts-once --ignore-rate-limit uses
0. FetchAll returns what it fetched before an error along with it, and
the workers save it, so a failed run no longer loses its data.
findatender's FetchAll and FetchOnce take RequestOptions, which gains
Until (updatedTo), and RateLimitRetries replaces AllowRateLimit.
This commit is contained in:
bwilliams committed 2026-10-21 12:40:39 +01:00
1 parent ff2aa316b5
commit c09c30ae71
16 files changed
+683 -149

No files matched your search

+13 -2
View File
@@ -7,10 +7,12 @@ const JSCKSourceFTSMock string = "fts_mock"
// JSCSourceFTSMock configures fetching from a Find a Tender mock
// server (cmd/mock-fts) at APIRoot, which has no default. Empty: the source
// fails to start if it is enabled.
// fails to start if it is enabled. RateLimitRetries is as for
// JSCSourceFindATender.
type JSCSourceFTSMock struct {
JSCSourcesSource
APIRoot string `cfg:"api_root"`
APIRoot string `cfg:"api_root"`
RateLimitRetries int `cfg:"rate_limit_retries" default:"5"`
}
// ---------- Section methods (see Section) ----------
@@ -37,3 +39,12 @@ func (c JSCSourceFTSMock) ValueOf(key string) (any, error) {
func (c *JSCSourceFTSMock) SetValue(key string, value any) error {
return setValue(c, key, value)
}
// ---------- Section specific methods ----------
// validate checks values before they are stored (see validator), as
// JSCSourcesSource's does, which this one hides. rate_limit_retries can't be
// negative.
func (c *JSCSourceFTSMock) validate(key string, value any) error {
return validateRateLimitRetries(&c.JSCSourcesSource, key, value)
}