Skip to content

Commit

Permalink
[FEAT] Async Consumer-based Klatchat Observer (#109)
Browse files Browse the repository at this point in the history
* Enabled async consumers for Chatbots Observer and updated neon mq connector requirements
  • Loading branch information
NeonKirill authored Dec 3, 2024
1 parent be65e64 commit cb30b81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ httpx==0.27.0 # required by FastAPI
Jinja2==3.1.3
jsbeautifier==1.15.1
kubernetes==29.0.0
neon-mq-connector~=0.7
neon-mq-connector==0.7.2a5
neon-sftp~=0.1
neon_utils[sentry]==1.11.1a5
pre-commit==3.7.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/services/observer.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
neon-mq-connector~=0.7
neon-mq-connector==0.7.2a5
websocket-client==1.7.0
websockets==12.0
8 changes: 4 additions & 4 deletions services/klatchat_observer/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Recipients(Enum):
class ChatObserver(MQConnector):
"""Observer of conversations states"""

async_consumers_enabled = True

recipient_prefixes = {
Recipients.NEON: ["neon"],
Recipients.UNRESOLVED: ["undefined"],
Expand Down Expand Up @@ -509,9 +511,7 @@ def handle_message(self, data: dict):
or Recipients.UNRESOLVED
)
handler_method = self.recipient_to_handler_method.get(recipient)
if not handler_method:
LOG.warning(f"Failed to get handler message for recipient={recipient}")
else:
if handler_method:
handler_method(recipient_data=recipient_data, msg_data=data)
else:
raise TypeError(f"Malformed data received: {data}")
Expand Down Expand Up @@ -569,7 +569,7 @@ def send_translation_response(self, data: dict):
if request_id and self.__translation_requests.pop(request_id, None):
self.sio.emit("get_neon_translations", data=data)
else:
LOG.warning(
LOG.debug(
f"Neon translation response was not sent, "
f"as request_id={request_id} was not found among translation requests"
)
Expand Down

0 comments on commit cb30b81

Please sign in to comment.