feat(youtube): process-wide caption-fetch rate gate (ADR-014 item 2)
ADR-014 item 2 — a single per-egress-IP rate gate shared by every caption fetch — was specced but only per-video backoff (rate_limited_at) shipped. Build the real gate now: it is load-bearing once ADR-018 puts auto-summarize on an in-process schedule across multiple users (all fetches leave one pod's egress IP, concurrently with live "Summarize" clicks — without a shared gate that self-inflicts 429s every cycle). globalFetchGate (golang.org/x/time/rate, default 2s/req burst 1) is consulted in httpDo before every live outbound fetch — player, watch-page, timedtext — so the scheduler runners and the web click-path serialise through one limiter regardless of how many users/goroutines are upstream. The test seam (a.transport != nil) skips the gate so fakes are not throttled. TAPIR_FETCH_RATE (Go duration, default 2s, 0 = unlimited) wires SetFetchRate in cmdRun; the existing per-video backoff stays as the complementary 429 handler. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,18 @@ TAPIR_POLL_INTERVAL=
|
||||
# caption endpoint; after it expires the video is retried. 0 = always retry.
|
||||
# Go duration; default 1h.
|
||||
TAPIR_FETCH_BACKOFF=
|
||||
# Minimum interval between outbound caption fetches across the WHOLE process —
|
||||
# the shared per-egress-IP rate gate (ADR-014). Scheduler runners and the web
|
||||
# "Summarize" click-path serialise through it so they cannot collectively trip
|
||||
# 429s. Go duration; default 2s. 0 = unlimited (dev/tests).
|
||||
TAPIR_FETCH_RATE=
|
||||
|
||||
# --- scheduled discovery (tapir serve, ADR-018) ---------------------------
|
||||
# When > 0, `serve` runs in-process discovery for ALL users on this cadence
|
||||
# (e.g. 2h): one runner pass per user per tick, run-once-on-startup then ticked.
|
||||
# Empty/0 = disabled (dev/tests never auto-fetch). SINGLE-REPLICA assumption —
|
||||
# >1 replica double-runs discovery. Go duration.
|
||||
TAPIR_DISCOVERY_INTERVAL=
|
||||
|
||||
# --- invitations (tapir invite) -------------------------------------------
|
||||
# Public base URL used to build the invite link `tapir invite <email>` prints.
|
||||
|
||||
Reference in New Issue
Block a user