chore: adjust message/command structure and write unit tests

ref: N25B-205
This commit is contained in:
Björn Otgaar
2025-10-23 12:54:53 +02:00
parent 530fc42c50
commit 1f8d769762
7 changed files with 90 additions and 12 deletions

View File

@@ -0,0 +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()
@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"}