fix: endpoints don't create sockets
ref: N25B-217
This commit is contained in:
@@ -17,8 +17,7 @@ async def receive_command(command: SpeechCommand, request: Request):
|
||||
# Validate and retrieve data.
|
||||
SpeechCommand.model_validate(command)
|
||||
topic = b"command"
|
||||
pub_socket = Context.instance().socket(zmq.PUB)
|
||||
pub_socket.connect(settings.zmq_settings.internal_pub_address)
|
||||
pub_socket = request.app.state.endpoints_pub_socket
|
||||
await pub_socket.send_multipart([topic, command.model_dump_json().encode()])
|
||||
|
||||
return {"status": "Command received"}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import logging
|
||||
|
||||
import zmq
|
||||
from fastapi import APIRouter, Request
|
||||
from zmq.asyncio import Context
|
||||
|
||||
from control_backend.core.config import settings
|
||||
from control_backend.schemas.message import Message
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -19,8 +16,7 @@ async def receive_message(message: Message, request: Request):
|
||||
topic = b"message"
|
||||
body = message.model_dump_json().encode("utf-8")
|
||||
|
||||
pub_socket = Context.instance().socket(zmq.PUB)
|
||||
pub_socket.bind(settings.zmq_settings.internal_pub_address)
|
||||
pub_socket = request.app.state.endpoints_pub_socket
|
||||
await pub_socket.send_multipart([topic, body])
|
||||
|
||||
return {"status": "Message received"}
|
||||
|
||||
Reference in New Issue
Block a user