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.

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.

Download files

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

Source Distribution

py_stinger_conn_iface-0.1.0.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

py_stinger_conn_iface-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file py_stinger_conn_iface-0.1.0.tar.gz.

File metadata

  • Download URL: py_stinger_conn_iface-0.1.0.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for py_stinger_conn_iface-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60f1f15eb63ca898f547e23a0c4deea09ebc5afa7c236c3c818afca962fe4b28
MD5 83122449fb3f8a6f1320f86fd472a4ad
BLAKE2b-256 fad6f001591fd079cf0d2e928fd9680c611fe223cb5882b151bd0e4f77707ebb

See more details on using hashes here.

File details

Details for the file py_stinger_conn_iface-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_stinger_conn_iface-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for py_stinger_conn_iface-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01bc8552d9144a98f1fa80ac089999255f4860b686be16ff0ccf8b966228a376
MD5 8302c3bdacfa3f210bebd7858c620708
BLAKE2b-256 bea1842bbce9bec50d023d2e7c0b2dafbee4755ab90b3c4e55430bd10c953217

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

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