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:
1 parent
ff2aa316b5
commit
c09c30ae71
16 files changed
+683
-149
No files matched your search
@@ -97,3 +97,17 @@ func (c *JSCSourcesSource) validate(key string, value any) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateRateLimitRetries is the validate of a Find a Tender source's
|
||||
// section: source's checks, then rate_limit_retries, which can't be
|
||||
// negative.
|
||||
func validateRateLimitRetries(
|
||||
source *JSCSourcesSource, key string, value any,
|
||||
) error {
|
||||
if key == "rate_limit_retries" && value.(int) < 0 {
|
||||
return errors.New(
|
||||
"config: rate_limit_retries can't be negative; 0 fails at the first rate limit",
|
||||
)
|
||||
}
|
||||
return source.validate(key, value)
|
||||
}
|
||||
Reference in new issue
Block a user