generated from pufereq/python-template
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
085c34f232 | ||
|
e8ef578141
|
|||
|
|
3d5a1e95da | ||
|
4bba344e8a
|
|||
|
29bf802356
|
13
CHANGELOG.md
13
CHANGELOG.md
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.9.1] - 2026-03-05
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [`e8ef578`](https://gitea.pufereq.pl/judas/judas_protocol/commit/e8ef578141c7f7ea5ee1ee5fb9e9a22a73fd1cc2) **message.py**: fix error on TELEMETRY msg
|
||||
|
||||
## [0.9.0] - 2026-03-05
|
||||
|
||||
### Features
|
||||
|
||||
- [`4bba344`](https://gitea.pufereq.pl/judas/judas_protocol/commit/4bba344e8abcd64947c06b371ae84ca8f0591a9c) **message.py**: add `Message.Telemetry` factory class
|
||||
- [`29bf802`](https://gitea.pufereq.pl/judas/judas_protocol/commit/29bf80235631f069be519e3e3ac0772c9a9d44db) **types.py**: add `TELEMETRY` category
|
||||
|
||||
## [0.8.0] - 2026-03-03
|
||||
|
||||
### Features
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
||||
|
||||
[project]
|
||||
name = "judas_protocol"
|
||||
version = "0.8.0"
|
||||
version = "0.9.1"
|
||||
description = "The judas protocol"
|
||||
readme = "README.md"
|
||||
authors = []
|
||||
|
||||
@@ -5,7 +5,12 @@ import json
|
||||
import uuid
|
||||
from typing import Any, override
|
||||
|
||||
from judas_protocol.types import ActionType, Category, ControlAction
|
||||
from judas_protocol.types import (
|
||||
ActionType,
|
||||
Category,
|
||||
ControlAction,
|
||||
TelemetryAction,
|
||||
)
|
||||
|
||||
|
||||
class Message:
|
||||
@@ -108,6 +113,66 @@ class Message:
|
||||
ack_required=True,
|
||||
)
|
||||
|
||||
class Telemetry:
|
||||
"""TELEMETRY category message factory methods."""
|
||||
|
||||
@staticmethod
|
||||
def initial(payload: dict[str, Any]) -> Message:
|
||||
"""Create an INITIAL telemetry message.
|
||||
|
||||
Args:
|
||||
payload (dict[str, Any]): The payload of the message.
|
||||
|
||||
Returns:
|
||||
Message: The created INITIAL telemetry message.
|
||||
"""
|
||||
return Message(
|
||||
id_=None,
|
||||
category=Category.TELEMETRY,
|
||||
action=TelemetryAction.INITIAL,
|
||||
payload=payload,
|
||||
acknowledged=False,
|
||||
ack_required=True,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def update(payload: dict[str, Any]) -> Message:
|
||||
"""Create an UPDATE telemetry message.
|
||||
|
||||
Args:
|
||||
payload (dict[str, Any]): The payload of the message.
|
||||
|
||||
Returns:
|
||||
Message: The created UPDATE telemetry message.
|
||||
"""
|
||||
return Message(
|
||||
id_=None,
|
||||
category=Category.TELEMETRY,
|
||||
action=TelemetryAction.UPDATE,
|
||||
payload=payload,
|
||||
acknowledged=False,
|
||||
ack_required=False,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def on_demand(payload: dict[str, Any]) -> Message:
|
||||
"""Create an ON_DEMAND telemetry message.
|
||||
|
||||
Args:
|
||||
payload (dict[str, Any]): The payload of the message.
|
||||
|
||||
Returns:
|
||||
Message: The created ON_DEMAND telemetry message.
|
||||
"""
|
||||
return Message(
|
||||
id_=None,
|
||||
category=Category.TELEMETRY,
|
||||
action=TelemetryAction.ON_DEMAND,
|
||||
payload=payload,
|
||||
acknowledged=False,
|
||||
ack_required=True,
|
||||
)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
"""Convert the message to a dictionary.
|
||||
|
||||
@@ -161,6 +226,8 @@ class Message:
|
||||
match category:
|
||||
case Category.CONTROL:
|
||||
action = ControlAction(action_str)
|
||||
case Category.TELEMETRY:
|
||||
action = TelemetryAction(action_str)
|
||||
case _:
|
||||
raise ValueError(f"Unknown category: {category}")
|
||||
|
||||
|
||||
@@ -5,14 +5,21 @@ from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
|
||||
type ActionType = ControlAction
|
||||
type ActionType = ControlAction | TelemetryAction
|
||||
|
||||
|
||||
class Category(str, Enum):
|
||||
CONTROL = "control"
|
||||
TELEMETRY = "telemetry"
|
||||
|
||||
|
||||
class ControlAction(str, Enum):
|
||||
HELLO = "hello"
|
||||
ACK = "ack"
|
||||
CLOSE = "close"
|
||||
|
||||
|
||||
class TelemetryAction(str, Enum):
|
||||
INITIAL = "initial"
|
||||
UPDATE = "update"
|
||||
ON_DEMAND = "on_demand"
|
||||
|
||||
Reference in New Issue
Block a user