Skip to content

Replace Redis with SQLite for storage and job queue#202

Merged
dir01 merged 5 commits intomasterfrom
feature/no-redis
Mar 1, 2026
Merged

Replace Redis with SQLite for storage and job queue#202
dir01 merged 5 commits intomasterfrom
feature/no-redis

Conversation

@dir01
Copy link
Copy Markdown
Owner

@dir01 dir01 commented Feb 28, 2026

  • Storage: new storage/sqlite.go (NewSQLiteStorage) replaces Redis key-value store
  • Queue: new service/jobs_queue/sqlq_queue.go using github.com/dir01/sqlq replaces taylorchu/work
  • Uses modernc.org/sqlite (pure Go) to avoid CGO symbol conflicts with torrent library
  • Env var SQLITE_DB_PATH replaces REDIS_URL (default: ./mediary.db)
  • Single shared *sql.DB opened with WAL + busy_timeout pragmas
  • Tests now use in-memory SQLite — no Docker/testcontainers needed for queue or storage tests
  • Lint: local golangci-lint replaces Docker-based runner in Makefile and CI uses golangci-lint-action

dir01 and others added 4 commits February 28, 2026 16:54
- Storage: new storage/sqlite.go (NewSQLiteStorage) replaces Redis key-value store
- Queue: new service/jobs_queue/sqlq_queue.go using github.com/dir01/sqlq replaces taylorchu/work
- Uses modernc.org/sqlite (pure Go) to avoid CGO symbol conflicts with torrent library
- Env var SQLITE_DB_PATH replaces REDIS_URL (default: ./mediary.db)
- Single shared *sql.DB opened with WAL + busy_timeout pragmas
- Tests now use in-memory SQLite — no Docker/testcontainers needed for queue or storage tests
- Lint: local golangci-lint replaces Docker-based runner in Makefile and CI uses golangci-lint-action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace do_lint_test.yml with do_lint.yml and do_test.yml so they run
in parallel and report independently on PRs and master pushes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Propagate per-job context from sqlq through Subscribe handler
  so spans and timeouts from the queue flow into job processing
- Change Subscribe handler signature to include context.Context
- Fix Start() to call Run() before Subscribe() so the schema
  is initialized before consumers begin polling
- Set 2-hour default job timeout (matching old taylorchu/work behavior)
- Regenerate mocks after interface change
- Update golden test fixtures to match current magnetURL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of relying on external torrents from the internet, the tests now
spin up a local anacrolix torrent client as a seeder and wire it into the
downloader via AddBootstrapPeer. This makes metadata tests fast, reliable,
and deterministic — no DHT or internet access required.

- downloader/torrent: add AddBootstrapPeer + addMagnet helper that calls
  AddClientPeer for each registered seeder after AddMagnet
- tests/local_seeder.go: SetupLocalSeeder helper creates a temp dir with
  provided files, builds metainfo, seeds it, and returns the canonical
  magnet URL (infohash only, no dn/tr params)
- tests/e2e_test.go: replace the external magnetURL constant with a local
  seeder; use an unreachable infohash for the "timeout" subtest; move S3
  setup to top-level with panic recovery so metadata subtests run without
  Docker
- Update golden files to match new local test torrent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dir01 dir01 force-pushed the feature/no-redis branch 2 times, most recently from b55fc65 to a982d40 Compare March 1, 2026 18:04
- Add SetupLocalSeeder helper to seed fake torrent data locally in tests,
  eliminating reliance on external torrent availability
- Add MakeMinimalMP3 helper (uses ffmpeg) to generate valid MP3 bytes for
  job creation tests; reduces job test timeout from 50m to 2m
- Wire local seeders into the torrent downloader via AddBootstrapPeer for
  direct peer exchange (no DHT or trackers required)
- Use a temp-file SQLite DB with WAL mode in e2e tests instead of
  in-memory (in-memory silently ignores WAL, causing write contention
  under sqlq's read transaction)
- Fix concatenate_flow.go: use per-call statusCtx instead of a shared
  1-second context that expires before later SaveJob calls complete
- Handle Docker-unavailable panic from testcontainers at top level with
  recover(); S3-dependent subtests skip gracefully when s3Client is nil

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dir01 dir01 force-pushed the feature/no-redis branch from a982d40 to da0cfcc Compare March 1, 2026 18:38
@dir01 dir01 merged commit 62e4c13 into master Mar 1, 2026
4 checks passed
@dir01 dir01 deleted the feature/no-redis branch March 1, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant