feat: wire adapter registry into worker loop
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()]
|
||||
@@ -0,0 +1,9 @@
|
||||
from lyra_worker.registry import build_adapters
|
||||
|
||||
|
||||
def test_registry_returns_the_three_fake_sources():
|
||||
adapters = build_adapters()
|
||||
names = sorted(a.name for a in adapters)
|
||||
assert names == ["qobuz", "soulseek", "youtube"]
|
||||
for a in adapters:
|
||||
assert a.health() is True
|
||||
Reference in New Issue
Block a user