Librarian: answer each query back to the bot that sent it
So one librarian can serve several bots (test + deploy) instead of firing
every result/pong at a single static CONJURER_MAIN_BOT.
* The bot includes its own callback address (CONJURER_SELF_CALLBACK) in
every /query and /ping.
* The librarian stores that callback with the query (persisted with the
request, so a replay after restart still answers the right bot) and, for
results, in the OUTBOX entry ({target, payload}) so the resender delivers
to the origin bot even across a librarian restart.
* Pongs go back to the pinging bot too - otherwise a second bot's health
check would be ponged to the first and always time out, so it could
never enable its librarian cog.
* Empty callback falls back to MAIN_BOT_ADDRESS, and a legacy OUTBOX entry
(raw payload, pre-callback) is still delivered to the default bot, so the
upgrade is seamless.
Tests: per-origin result delivery + legacy-shape fallback (outbox),
busy/idle pong routed to the callback bot vs default (lifecycle). Suite:
58 unit + 52 integration green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ from constants import (
|
||||
DIR_PATH_SADOX,
|
||||
LIBRARIAN_SERVICE_ADDRESS,
|
||||
QUERY_STATUS,
|
||||
SELF_CALLBACK,
|
||||
SEND_QUERY,
|
||||
service_headers,
|
||||
)
|
||||
@@ -313,6 +314,7 @@ class DataModule(commands.Cog):
|
||||
"query": str(query),
|
||||
"page": 1,
|
||||
"deep_search": False,
|
||||
"callback": SELF_CALLBACK,
|
||||
}
|
||||
coroutine = asyncio.to_thread(
|
||||
requests.post,
|
||||
@@ -372,6 +374,7 @@ class DataModule(commands.Cog):
|
||||
"query": str(query),
|
||||
"page": 1,
|
||||
"deep_search": False,
|
||||
"callback": SELF_CALLBACK,
|
||||
}
|
||||
coroutine = asyncio.to_thread(
|
||||
requests.post,
|
||||
@@ -469,6 +472,7 @@ class DataModule(commands.Cog):
|
||||
"query": str(query),
|
||||
"page": 1,
|
||||
"deep_search": True,
|
||||
"callback": SELF_CALLBACK,
|
||||
}
|
||||
coroutine = asyncio.to_thread(
|
||||
requests.post,
|
||||
|
||||
Reference in New Issue
Block a user