stinger-python-utils
Shared utilities for Stinger Python services, providing convenient message creation for MQTT communication.
Installation
uv add stinger-python-utils
MessageCreator
MessageCreator is a utility class for creating MQTT messages with standardized properties and payloads.
Basic Usage
from pydantic import BaseModel
from stinger_python_utils.message_creator import MessageCreator
class MyPayload(BaseModel):
name: str
value: int
payload = MyPayload(name="test", value=42)
message = MessageCreator.signal_message("my/topic", payload)
Methods
| Method | Purpose | Return Code |
|---|---|---|
signal_message(topic, payload) |
Send a signal with one-time delivery | QoS 1, no retain |
status_message(topic, payload, expiry_seconds) |
Send status that expires | QoS 1, retained, with expiry |
error_response_message(topic, return_code, correlation_id, debug_info) |
Error response to a request | QoS 1, user properties: ReturnCode |
response_message(topic, payload, return_code, correlation_id) |
Successful response to a request | QoS 1, user properties: ReturnCode |
property_state_message(topic, payload, state_version) |
Publish property state | QoS 1, retained, JSON content type |
property_update_request_message(topic, payload, version, response_topic, correlation_id) |
Request property update | QoS 1, user property: PropertyVersion |
property_response_message(topic, payload, version, return_code, correlation_id, debug_info) |
Respond to property update | QoS 1, user properties: ReturnCode, PropertyVersion |
request_message(topic, payload, response_topic, correlation_id) |
Send a request (auto-generates UUID if no correlation_id) | QoS 1, auto correlation ID |
Example: Request/Response Pattern
from pydantic import BaseModel
from stinger_python_utils.message_creator import MessageCreator
class Request(BaseModel):
action: str
request = Request(action="start")
msg = MessageCreator.request_message(
"devices/cmd",
request,
response_topic="devices/response"
)
# Returns a Message with auto-generated correlation ID
Example: Error Response
msg = MessageCreator.error_response_message(
"devices/response",
return_code=500,
correlation_id="req-123",
debug_info="Device not found"
)
# User properties include: ReturnCode=500, DebugInfo=Device not found
Metadata
Release files for stinger-python-utils 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stinger_python_utils-0.2.0.tar.gz | 102.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stinger_python_utils-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.7 kB
Release files / stinger_python_utils-0.2.0.tar.gz
| Download URL | stinger_python_utils-0.2.0.tar.gz |
|---|---|
| Size | 102.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ceb29e7951408de4a289c220aefbdc104d45696ec165d55296c21278412c8b58
|
|
BLAKE2b-256 checksum How to use checksums |
56dfa4f523ab83c59edef03e5674ac54b28e507392b4fd39d8a1d5fa8d3ab756
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / stinger_python_utils-0.2.0-py3-none-any.whl
| Download URL | stinger_python_utils-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f23617b15d9e4e711f4d4bc49509df3c9a88b4deec9933f656d5b8e3a86d5c34
|
|
BLAKE2b-256 checksum How to use checksums |
bbb6c86b0e24d147866fab2096db65ad9762f3e81296c4f726e16183ed635ae3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|