Skip to main content

py-stinger-conn-iface

The interface for Python stinger connections.

This package defines the abstract, broker-agnostic interface that stinger-ipc broker connection implementations (e.g. MQTT) implement, along with the small set of value types (Message, ContentType) used to describe messages passing through that interface. It contains no broker-specific logic itself.

Supports Python 3.7+.

Installation

pip install py-stinger-conn-iface

Or, with uv:

uv add py-stinger-conn-iface

Contents

Message

A dataclass describing a single message to publish or that has been received.

from pystingerconniface import Message

msg = Message(topic="devices/123/status", payload=b'{"online": true}', qos=1, retain=True)
msg.set_user_property("trace-id", "abc123")
Field Type Description
topic str The topic the message is published to or received on.
payload bytes The raw message payload.
qos int The quality-of-service level for the message.
retain bool Whether the broker should retain the message on the topic.
content_type str | ContentType | None The content type of the payload, if any.
correlation_data bytes | None Correlation data for request/response patterns.
response_topic str | None Topic the receiver should reply to, if any.
subscription_ids list[int] Subscription identifiers a received message matched. Ignored on publish.
message_expiry_interval int | None Seconds after which the broker may discard the message.
user_properties dict[str, str] Arbitrary user-defined key/value metadata.

Message also converts to and from the shapes MQTT client libraries use. No client library is a dependency of this package: the inbound conversions are duck-typed, and paho_kwargs() imports paho-mqtt only when it is called.

# Publishing with paho-mqtt (requires paho-mqtt to be installed by the caller).
client.publish(**msg.paho_kwargs())

# Receiving, in a paho-mqtt on_message callback.
msg = Message.from_paho_message(paho_msg)
Method Description
mqtt_properties() The message's MQTT v5 PUBLISH properties as a dict keyed by their spec names (ContentType, UserProperty, ...). Unset properties are omitted.
set_mqtt_properties(properties) Applies such a dict onto the message. Unknown keys are ignored, so a client library's property object can be passed through as-is.
Message.from_mqtt_message(msg) Builds a Message from any received-message object with topic, payload, qos and retain attributes, plus an optional properties mapping or attribute carrier.
paho_kwargs() The keyword arguments for a paho-mqtt Client.publish() call, including a populated Properties object.
Message.from_paho_message(paho_msg) from_mqtt_message() under the name paho callers expect.

ContentType

A str subclass for parsing and constructing HTTP-style Content-Type header values, including their parameters (e.g. charset).

from pystingerconniface import ContentType

ct = ContentType("application/json; charset=utf-8")
ct == "application/json"          # True, ContentType is a str subclass
ct.parameters                     # {"charset": "utf-8"}
ct.charset                        # "utf-8" (also available as an attribute)
ct.to_header()                    # "application/json; charset=utf-8"

IBrokerConnection

An abstract base class describing the operations a broker connection implementation must provide: publishing messages, subscribing to topics, registering message callbacks, and reporting connection state.

from pystingerconniface import IBrokerConnection, Message

class MyBrokerConnection(IBrokerConnection):
    def publish(self, message: Message):
        ...

    def subscribe(self, topic, callback=None, qos=1):
        ...

    def add_message_callback(self, callback):
        ...

    def is_topic_sub(self, topic, sub):
        ...

    @property
    def online_topic(self):
        ...

    @property
    def client_id(self):
        ...

    def is_connected(self):
        ...

IBrokerConnection also provides a concrete unpublish_retained(topic) helper that publishes an empty, retained message to clear a previously retained message from a topic.

Development

This project uses uv for dependency management.

uv sync              # install runtime and dev dependencies
uv run pytest         # run the test suite
uv run ruff check .   # lint
uv run black .        # format
uv run mypy src tests # type check

License

MIT — see LICENSE.

Metadata

Release files for py-stinger-conn-iface 0.1.2

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

Source distribution (sdist)

Source distribution for py-stinger-conn-iface 0.1.2
File Size Uploaded Provenance Actions
py_stinger_conn_iface-0.1.2.tar.gz 36.4 kB Without provenance Details for py_stinger_conn_iface-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-stinger-conn-iface 0.1.2
File Interpreter ABI Platform Actions
py_stinger_conn_iface-0.1.2-py3-none-any.whl Python 3 none any Details for py_stinger_conn_iface-0.1.2-py3-none-any.whl

Total release size: 44.7 kB

Release files / py_stinger_conn_iface-0.1.2.tar.gz

Download URL py_stinger_conn_iface-0.1.2.tar.gz
Size 36.4 kB
Tags Source
SHA-256 checksum
How to use checksums
092f4d1b55d83949a0d533a28ac1e5c48a880c1032ca64d3294682cc61a43004
BLAKE2b-256 checksum
How to use checksums
888ed18a5f5a720497777937da43289fdb527c18b4af2cfdbddfa1741414452d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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 / py_stinger_conn_iface-0.1.2-py3-none-any.whl

Download URL py_stinger_conn_iface-0.1.2-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a57b4f09182df26a127e11097cd78a35b04b4582cc24d6eeed6d1116b87af941
BLAKE2b-256 checksum
How to use checksums
6aab432cb99e4c3aec062291181e278b0e9958eb3a1ff75c414b964eb93d7d3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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}

Security for py-stinger-conn-iface 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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