veza/veza-backend-api/internal/workers
senke 70f0fb1636 feat(transcode): read from S3 signed URL when track is s3-backed (v1.0.8 P2)
Closes the transcoder's read-side gap for Phase 2. HLS transcoding now
works for tracks uploaded under TRACK_STORAGE_BACKEND=s3 without
requiring the stream server pod to share a local volume.

Changes:

- internal/services/hls_transcode_service.go
  - New SignedURLProvider interface (minimal: GetSignedURL).
  - HLSTranscodeService gains optional s3Resolver + SetS3Resolver.
  - TranscodeTrack routed through new resolveSource helper — returns
    local FilePath for local tracks, a 1h-TTL signed URL for s3-backed
    rows. Missing resolver for an s3 track returns a clear error.
  - os.Stat check skipped for HTTP(S) sources (ffmpeg validates them).
  - transcodeBitrate takes `source` explicitly so URL propagation is
    obvious and ValidateExecPath is bypassed only for the known
    signed-URL shape.
  - isHTTPSource helper (http://, https:// prefix check).

- internal/workers/job_worker.go
  - JobWorker gains optional s3Resolver + SetS3Resolver.
  - processTranscodingJob skips the local-file stat when
    track.StorageBackend='s3', reads via signed URL instead.
  - Passes w.s3Resolver to NewHLSTranscodeService when non-nil.

- internal/config/config.go: DI wires S3StorageService into JobWorker
  after instantiation (nil-safe).

- internal/core/track/service.go (copyFileAsyncS3)
  - Re-enabled stream server trigger: generates a 1h-TTL signed URL
    for the fresh s3 key and passes it to streamService.StartProcessing.
    Rust-side ffmpeg consumes HTTPS URLs natively. Failure is logged
    but does not fail the upload (track will sit in Processing until
    a retry / reconcile).

- internal/core/track/track_upload_handler.go (CompleteChunkedUpload)
  - Reload track after S3 migration to pick up the new storage_key.
  - Compute transcodeSource = signed URL (s3 path) or finalPath (local).
  - Pass transcodeSource to both streamService.StartProcessing and
    jobEnqueuer.EnqueueTranscodingJob — dual-trigger preserved per
    plan D2 (consolidation deferred v1.0.9).

- internal/services/hls_transcode_service_test.go
  - TestHLSTranscodeService_TranscodeTrack_EmptyFilePath updated for
    the expanded error message ("empty FilePath" vs "file path is empty").

Known limitation (v1.0.9): HLS segment OUTPUT still writes to the
local outputDir; only the INPUT side is S3-aware. Multi-pod HLS serving
needs the worker to upload segments to MinIO post-transcode. Acceptable
for v1.0.8 target — single-pod staging supports both local + s3 tracks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 23:34:51 +02:00
..
analytics_job.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
analytics_job_test.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
email_job.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
email_job_test.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
hard_delete_worker.go fix(backend): J4 — GDPR-compliant hard delete with Redis and ES cleanup 2026-04-15 12:25:39 +02:00
hard_delete_worker_test.go fix(backend): J4 — GDPR-compliant hard delete with Redis and ES cleanup 2026-04-15 12:25:39 +02:00
hls_transcode_worker.go refonte: backend-api go first; phase 1 2025-12-12 21:34:34 -05:00
job_worker.go feat(transcode): read from S3 signed URL when track is s3-backed (v1.0.8 P2) 2026-04-23 23:34:51 +02:00
job_worker_test.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
playback_analytics_worker.go refonte: backend-api go first; phase 1 2025-12-12 21:34:34 -05:00
playback_analytics_worker_test.go stabilizing veza-backend-api: phase 1 2025-12-16 11:23:49 -05:00
playback_retention_worker.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
playback_retention_worker_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
thumbnail_job.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
thumbnail_job_test.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
video_transcode_worker.go feat(v0.12.3): F276-F305 video upload, HLS transcoding, education tests 2026-03-11 19:20:48 +01:00
webhook_worker.go refonte: backend-api go first; phase 1 2025-12-12 21:34:34 -05:00