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:
co-authored by
Claude Fable 5.2
parent
9c9d641eda
commit
7d4893bc3f
@@ -2,12 +2,17 @@ GO ?= go
|
||||
BIN := bin
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
|
||||
.PHONY: all build test race vet fmt check run e2e clean
|
||||
.PHONY: all build faketelegram test test-postgres race vet fmt check run e2e acceptance clean
|
||||
|
||||
all: check build
|
||||
|
||||
build:
|
||||
$(GO) build -trimpath -ldflags "-s -w" -o $(BIN)/core ./cmd/core
|
||||
$(GO) build -trimpath -ldflags "-s -w" -o $(BIN)/worker ./cmd/worker
|
||||
|
||||
# Fake Telegram Bot API, for trying the bot without a token.
|
||||
faketelegram:
|
||||
$(GO) build -o $(BIN)/faketelegram ./cmd/faketelegram
|
||||
|
||||
test:
|
||||
$(GO) test ./...
|
||||
@@ -27,6 +32,18 @@ check: fmt vet race
|
||||
run: build
|
||||
./$(BIN)/core
|
||||
|
||||
# The same test suite against Postgres. Point PG_DSN at an empty database;
|
||||
# each test creates and drops its own schema in it.
|
||||
# make test-postgres PG_DSN=postgres://user:pass@127.0.0.1:5432/dlbot_test?sslmode=disable
|
||||
test-postgres:
|
||||
@test -n "$(PG_DSN)" || { echo "set PG_DSN, see the comment in the Makefile"; exit 1; }
|
||||
DLBOT_TEST_DB=postgres DLBOT_TEST_PG_DSN="$(PG_DSN)" $(GO) test -count=1 ./...
|
||||
|
||||
# Kill a worker mid-job and watch the other one finish it. MODE=compose
|
||||
# runs it in containers.
|
||||
acceptance:
|
||||
deploy/acceptance/kill-worker.sh
|
||||
|
||||
# End-to-end test with the real yt-dlp and ffmpeg. Needs network access.
|
||||
e2e:
|
||||
DLBOT_E2E_YTDLP=$${YTDLP_PATH:-$$(command -v yt-dlp)} $(GO) test -count=1 -v -run TestRealYtDlp ./internal/app
|
||||
|
||||
Reference in New Issue
Block a user