feat(config): TAPIR_FETCH_BACKOFF for rate-limit retry window
Adds FetchBackoff (Go duration, default 1h) controlling how long the run loop waits before re-fetching a transcript that returned HTTP 429. Zero means always retry. Not required by ValidateForRun — a zero/unset value is a valid policy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,12 @@ type Config struct {
|
||||
// PollInterval, when > 0, makes `run` loop on that cadence; 0 means run once.
|
||||
PollInterval time.Duration
|
||||
|
||||
// FetchBackoff is how long the run loop waits before re-fetching a transcript
|
||||
// that previously returned HTTP 429 (rate_limited). Inside the window the video
|
||||
// is skipped without hitting the caption endpoint, saving requests; after it
|
||||
// expires the video is retried. Zero means "always retry" (no backoff).
|
||||
FetchBackoff time.Duration
|
||||
|
||||
// HTTPAddr is the listen address for `tapir serve` (the Stage-0 web UI).
|
||||
HTTPAddr string
|
||||
|
||||
@@ -85,6 +91,7 @@ const (
|
||||
defaultYTConnectRedirectURL = "https://tapir.d-ma.be/oauth/youtube/callback"
|
||||
defaultOAuthRedirectAddr = "localhost:8080"
|
||||
defaultHTTPAddr = ":8080"
|
||||
defaultFetchBackoff = time.Hour
|
||||
)
|
||||
|
||||
// Load reads the environment into a Config, applying defaults. It does not
|
||||
@@ -124,6 +131,12 @@ func Load() (Config, error) {
|
||||
}
|
||||
c.PollInterval = interval
|
||||
|
||||
backoff, err := durationOr("TAPIR_FETCH_BACKOFF", defaultFetchBackoff)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
c.FetchBackoff = backoff
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user