feat(workers): runner loop + echo handler

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 04:43:52 +10:00
parent 3e1dcbb7f8
commit fba1ce48e4
4 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import json
from void_workers.runner import Runner
from void_workers.config import DATABASE_URL
def test_echo_handler_runs(boss_ready):
boss_ready.execute(
"INSERT INTO pgboss.job(name, data) VALUES('echo', %s)",
(json.dumps({"ping": 42}),)
)
runner = Runner(dsn=DATABASE_URL, handlers={"echo": {"concurrency": 1}})
runner.run(once=True)
row = boss_ready.execute(
"SELECT state, output FROM pgboss.job WHERE name='echo' "
"ORDER BY created_on DESC LIMIT 1"
).fetchone()
assert row[0] == "completed"
assert row[1] == {"pong": 42}