feat: wire adapter registry into worker loop

This commit is contained in:
Jonathan
2026-07-10 18:59:28 +02:00
parent 7c28eddd47
commit fbd6a056a4
3 changed files with 24 additions and 3 deletions
+4 -3
View File
@@ -3,13 +3,14 @@ import time
from lyra_worker.claim import claim_next
from lyra_worker.db import wait_for_db
from lyra_worker.pipeline import run_pipeline
from lyra_worker.registry import build_adapters
IDLE_SLEEP = 2.0
STAGE_DELAY = 1.0 # visible progress in the UI
def run_forever() -> None:
conn = wait_for_db()
adapters = build_adapters()
print("worker: waiting for jobs", flush=True)
try:
while True:
@@ -18,8 +19,8 @@ def run_forever() -> None:
time.sleep(IDLE_SLEEP)
continue
print(f"worker: claimed job {job_id}", flush=True)
run_pipeline(conn, job_id, stage_delay=STAGE_DELAY)
print(f"worker: imported job {job_id}", flush=True)
run_pipeline(conn, job_id, adapters)
print(f"worker: finished job {job_id}", flush=True)
finally:
conn.close()
+11
View File
@@ -0,0 +1,11 @@
from lyra_worker.adapters.base import SourceAdapter
from lyra_worker.adapters.fakes import FakeQobuz, FakeSoulseek, FakeYouTube
def build_adapters() -> list[SourceAdapter]:
"""The enabled source adapters, best-tier first.
SWAP POINT: Plan 3 replaces these fakes with real Qobuz/Soulseek/YouTube
adapters (reading credentials from config). Nothing else in the pipeline changes.
"""
return [FakeQobuz(), FakeSoulseek(), FakeYouTube()]