Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Using a more proper message type #3936

Merged
merged 6 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SOCKET_IO_LOG_EVENT,
SOCKET_IO_NODE_PROGRESS_EVENT,
SOCKET_IO_NODE_UPDATED_EVENT,
SOCKET_IO_PROJECT_PROGRESS_EVENT,
SocketMessageDict,
send_messages,
)
Expand Down Expand Up @@ -87,16 +88,21 @@ async def progress_message_parser(app: web.Application, data: bytes) -> bool:
return await _handle_computation_running_progress(app, rabbit_message)

# NOTE: other types of progress are transient
is_type_message_node = type(rabbit_message) == ProgressRabbitMessageNode
GitHK marked this conversation as resolved.
Show resolved Hide resolved
message = {
"event_type": SOCKET_IO_NODE_PROGRESS_EVENT,
"event_type": (
SOCKET_IO_NODE_PROGRESS_EVENT
if is_type_message_node
else SOCKET_IO_PROJECT_PROGRESS_EVENT
),
"data": {
"project_id": rabbit_message.project_id,
"user_id": rabbit_message.user_id,
"progress_type": rabbit_message.progress_type,
"progress": rabbit_message.progress,
},
}
if type(rabbit_message) == ProgressRabbitMessageNode:
if is_type_message_node:
message["node_id"] = rabbit_message.node_id
await send_messages(app, f"{rabbit_message.user_id}", [message])
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
SOCKET_IO_HEARTBEAT_EVENT: Final[str] = "set_heartbeat_emit_interval"
SOCKET_IO_EVENT: Final[str] = "event"
SOCKET_IO_NODE_PROGRESS_EVENT: Final[str] = "nodeProgress"
SOCKET_IO_PROJECT_PROGRESS_EVENT: Final[str] = "projectProgress"


class SocketMessageDict(TypedDict):
Expand Down