generated from pufereq/python-template
refactor(message.py): use ActionType instead of Enum
This commit is contained in:
@@ -3,10 +3,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
from enum import Enum
|
|
||||||
from typing import Any, override
|
from typing import Any, override
|
||||||
|
|
||||||
from judas_protocol.types import Category, ControlAction
|
from judas_protocol.types import ActionType, Category, ControlAction
|
||||||
|
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
@@ -16,7 +15,7 @@ class Message:
|
|||||||
self,
|
self,
|
||||||
id_: str | None,
|
id_: str | None,
|
||||||
category: Category,
|
category: Category,
|
||||||
action: Enum,
|
action: ActionType,
|
||||||
payload: dict[str, Any] | None = None,
|
payload: dict[str, Any] | None = None,
|
||||||
*,
|
*,
|
||||||
acknowledged: bool = False,
|
acknowledged: bool = False,
|
||||||
@@ -27,14 +26,14 @@ class Message:
|
|||||||
Args:
|
Args:
|
||||||
id_ (str | None): The ID of the message. If None, a new UUID will be generated.
|
id_ (str | None): The ID of the message. If None, a new UUID will be generated.
|
||||||
category (Category): The category of the message.
|
category (Category): The category of the message.
|
||||||
action (Enum): The action of the message.
|
action (ActionType): The action of the message.
|
||||||
payload (dict[str, Any] | None): The payload of the message.
|
payload (dict[str, Any] | None): The payload of the message.
|
||||||
acknowledged (bool): Whether the message has been acknowledged. Defaults to False.
|
acknowledged (bool): Whether the message has been acknowledged. Defaults to False.
|
||||||
ack_required (bool): Whether the message requires an acknowledgment. Defaults to False.
|
ack_required (bool): Whether the message requires an acknowledgment. Defaults to False.
|
||||||
"""
|
"""
|
||||||
self.id: str = id_ or str(uuid.uuid4())
|
self.id: str = id_ or str(uuid.uuid4())
|
||||||
self.category: Category = category
|
self.category: Category = category
|
||||||
self.action: Enum = action
|
self.action: ActionType = action
|
||||||
self.payload: dict[str, Any] = payload or {}
|
self.payload: dict[str, Any] = payload or {}
|
||||||
|
|
||||||
self.acknowledged: bool = acknowledged
|
self.acknowledged: bool = acknowledged
|
||||||
|
|||||||
Reference in New Issue
Block a user