Skip to main content

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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stinger-python-utils 0.3.0
File Size Uploaded
stinger_python_utils-0.3.0.tar.gz 102.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stinger-python-utils 0.3.0
File Interpreter ABI Platform
stinger_python_utils-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 108.8 kB

Release files / stinger_python_utils-0.3.0.tar.gz

Download URL stinger_python_utils-0.3.0.tar.gz
Size 102.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7a66b0707911db57c6c69feddc46a4a531a67189500ad6fd8c7e487c3639dd4b
BLAKE2b-256 checksum
How to use checksums
41d292b4987aa0c54d694455c5736081b8fc8d3918544b76b75f65fe3291aaea
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.3.0-py3-none-any.whl

Download URL stinger_python_utils-0.3.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e1077368ff645d5218ec7488ac261bd243596d70e21bd9f2bc631f68589a9b9
BLAKE2b-256 checksum
How to use checksums
0b0575ad46712123646ad646f3f246c23839413c73293199ade3c4a8349ffcbc
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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page