Phase 4: scale out

Remote workers, Postgres and S3, all chosen by configuration.

- Pull-based worker protocol over HTTP: claim (long poll), heartbeat,
  complete, fail, upload, source, probe. Workers need no inbound ports
- cmd/worker: standalone stateless worker with health endpoint and
  scheduled yt-dlp self-update
- Per-worker bearer tokens, stored hashed, revocable; identity always
  taken from the token; actions only on jobs the worker holds a lease for
- Tags: site_tags routes a site's jobs and lookups to workers that carry
  the required tags
- Drain, /workers, /ytdlp update, and "core worker add|revoke|list"
- Link lookups can run on remote workers (PROBE_MODE), so the core needs
  no yt-dlp and no residential address
- Postgres backend with pgx, same schema and queries; per-user advisory
  lock and job row lock where SQLite's serial writes were relied on
- The whole test suite runs on SQLite and on Postgres
- S3 storage backend with presigned worker uploads, sharing a conformance
  suite with the local backend
- Dockerfile with core, worker and faketelegram targets, docker-compose
  with optional Postgres and local Bot API server, systemd units
- deploy/acceptance/kill-worker.sh: kills a worker mid-job and checks
  that the other one delivers the file
- Fixes found on the way: /cancel could let the next playlist item start;
  a refund note could be missing when the sweep refunded first

Docker was not available on the build machine: the compose files were
validated with "docker compose config" only. The acceptance scenario was
run with real processes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 09:27:11 +00:00
co-authored by Claude Fable 5.2
parent 9c9d641eda
commit 7d4893bc3f
51 changed files with 4732 additions and 108 deletions
+20
View File
@@ -354,6 +354,18 @@ line = "{{.N}}. {{.Title}} · {{.Label}}"
# --- Owner commands ---------------------------------------------------------
[owner]
never = "never"
state_active = "active"
state_offline = "offline"
state_draining = "draining"
state_revoked = "revoked"
worker_embedded = "<b>embedded</b> · {{.Running}} of {{.Capacity}} slots busy"
worker_line = "<b>{{.Name}}</b> · {{.State}} · {{.Running}} of {{.Capacity}} slots busy · seen {{.Seen}} ago\ntags: {{.Tags}} · yt-dlp {{.Version}}"
worker_unknown = "There is no worker named <code>{{.Name}}</code>."
drain_usage = "Name the worker.\nExample: <code>/drain eu-1</code>, and <code>/drain eu-1 off</code> to bring it back."
drain_on = "Worker <code>{{.Name}}</code> is draining. It finishes its jobs and gets no new ones."
drain_off = "Worker <code>{{.Name}}</code> takes jobs again."
ytdlp_usage = "Use <code>/ytdlp update</code> to update yt-dlp on every worker."
purge_usage = "Send a link, or a key as <code>extractor:video_id</code>.\nExample: <code>/purge https://example.com/video copyright notice</code>"
cache = """
<b>Cache</b>
@@ -366,6 +378,14 @@ Taken down: {{.Blocked}}
Hit rate: {{.Rate}} of {{.Since}} requests
Download volume saved: {{.Saved}}"""
[owner.workers_header]
one = "<b>Workers</b>\n{{.Slots}} download slots online, {{.Count}} remote worker registered."
other = "<b>Workers</b>\n{{.Slots}} download slots online, {{.Count}} remote workers registered."
[owner.ytdlp_update]
one = "Asked {{.Count}} worker to update yt-dlp. It does so when it next checks for work."
other = "Asked {{.Count}} workers to update yt-dlp. They do so when they next check for work."
[owner.purged]
one = "Taken down: <code>{{.Key}}</code>\n{{.Count}} cached file was removed. The key is blocked."
other = "Taken down: <code>{{.Key}}</code>\n{{.Count}} cached files were removed. The key is blocked."