feat: add agent that is able to receive messages from UI

Inside the `/message` enpoint we put a message onto the internal event
queue, which gets read by TestAgent. This agent, in turn, logs the
message (temporary behaviour until we implement RI integration).

The name TestAgent is of course temporary, this is just for exploratory
purposes.

ref: N25B-165
This commit is contained in:
2025-10-08 18:27:24 +02:00
parent 71ddb5072b
commit 1eb414ea0d
5 changed files with 71 additions and 6 deletions

View File

@@ -1,13 +1,23 @@
from fastapi import APIRouter, Request
import logging
from zmq import Socket
from control_backend.schemas.message import Message
logger = logging.getLogger(__name__)
router = APIRouter()
# TODO: implement
@router.post("/message")
@router.post("/message", status_code=202)
async def receive_message(message: Message, request: Request):
logger.info("Received message: %s", message.message)
topic = b"message"
body = message.model_dump_json().encode("utf-8")
pub_socket: Socket = request.app.state.internal_comm_socket
pub_socket.send_multipart([topic, body])
return {"status": "Message received"}