stinger-python-utils 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stinger-python-utils
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Common utilities for Stinger Python services.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stinger-python-utils"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Common utilities for Stinger Python services."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,15 +1,13 @@
1
-
2
1
  from pyqttier.message import Message
3
2
  from pydantic import BaseModel
4
3
  from typing import Union, Optional
5
4
  import uuid
6
5
 
6
+
7
7
  class MessageCreator:
8
8
 
9
9
  @classmethod
10
- def signal_message(
11
- cls, topic: str, payload: BaseModel
12
- ) -> Message:
10
+ def signal_message(cls, topic: str, payload: BaseModel) -> Message:
13
11
  return Message(
14
12
  topic=topic,
15
13
  payload=payload.model_dump_json(by_alias=True).encode("utf-8"),
@@ -62,14 +60,19 @@ class MessageCreator:
62
60
  def response_message(
63
61
  cls,
64
62
  response_topic: str,
65
- response_obj: BaseModel|str|bytes,
63
+ response_obj: BaseModel | str | bytes,
66
64
  return_code: int,
67
65
  correlation_id: Union[str, bytes],
68
66
  ) -> Message:
69
67
  """
70
68
  This could be used for a successful response to a request.
71
69
  """
72
- payload = response_obj.model_dump_json(by_alias=True).encode("utf-8") if isinstance(response_obj, BaseModel) else response_obj
70
+ if isinstance(response_obj, BaseModel):
71
+ payload = response_obj.model_dump_json(by_alias=True).encode("utf-8")
72
+ elif isinstance(response_obj, str):
73
+ payload = response_obj.encode("utf-8")
74
+ else:
75
+ payload = response_obj
73
76
  msg_obj = Message(
74
77
  topic=response_topic,
75
78
  payload=payload,
@@ -1089,7 +1089,7 @@ wheels = [
1089
1089
 
1090
1090
  [[package]]
1091
1091
  name = "stinger-python-utils"
1092
- version = "0.1.1"
1092
+ version = "0.1.2"
1093
1093
  source = { editable = "." }
1094
1094
  dependencies = [
1095
1095
  { name = "pydantic", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" },