Skip to main content

Common utilities for Stinger Python services.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stinger_python_utils-0.1.8rc1.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stinger_python_utils-0.1.8rc1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file stinger_python_utils-0.1.8rc1.tar.gz.

File metadata

  • Download URL: stinger_python_utils-0.1.8rc1.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stinger_python_utils-0.1.8rc1.tar.gz
Algorithm Hash digest
SHA256 93964dcb2103c69ae3961eb04fa02709ad5242407315468dcbbd9a44207e66b1
MD5 64f7ea65027c6a29801ccbeca1424e85
BLAKE2b-256 db80b327556503ed40c86dbe7d7b47fe494539f9826f960fac6f369f649f5ffa

See more details on using hashes here.

File details

Details for the file stinger_python_utils-0.1.8rc1-py3-none-any.whl.

File metadata

  • Download URL: stinger_python_utils-0.1.8rc1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stinger_python_utils-0.1.8rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 eda3a40fb77be1720809d52e3785075dd4a8ea69bd65cc16bfa811d98b821bd4
MD5 9cec9c5b7884705f485f2e08f4ea752e
BLAKE2b-256 1278d18f86baf4657c51323a1f5b29cb0e4c9d3e8886923c73b0a56dedf61c53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page