Skip to main content

py-stinger-nng

Stinger-style IPC (signals, properties, methods) over NNG — a Python pub/sub broker implementing the IBrokerConnection interface with topic filtering, retained state, and cross-platform networking.

Features

  • Topic-filtered subscriptions: Subscribe to specific topics or topic prefixes
  • Retained state: Messages marked with retain=True are stored by the server and delivered to clients that join later
  • Client-to-client relaying: The server can relay messages between clients
  • Background connection management: Both client sockets dial in the background; reconnection is automatic after server restarts
  • Thread-safe: Safe to call from multiple threads and from within message callbacks

Installation

pip install py-stinger-nng

Quick Start

from py_stinger_nng import StingerNngServer, StingerNngClient
from pystingerconniface import Message

# Start a server on ports 15555 (publish) and 15556 (receive)
with StingerNngServer(15555, 15556) as server:
    # Create a client
    with StingerNngClient(15555, 15556) as client:
        # Subscribe to a topic
        def on_message(msg: Message) -> None:
            print(f"Received: {msg.topic} = {msg.payload}")
        
        client.subscribe("sensor/", on_message)
        
        # Publish a message
        msg = Message(topic="sensor/temperature", payload=b"21.5")
        client.publish(msg).result()

Architecture

  • StingerNngServer: Runs on two ports — PUB socket for publishing, PULL socket for receiving. Dispatches messages to all matching subscriptions, manages retained state, and relays client messages.
  • StingerNngClient: Connects to the server with SUB and PUSH sockets. Handles topic filtering at the socket level and syncs retained state on connect.

Key Methods

Both StingerNngServer and StingerNngClient implement IBrokerConnection:

  • publish(message) → Future[None]: Send a message
  • subscribe(topic, callback=None, qos=1) → int: Subscribe to a topic, returns a subscription ID
  • unsubscribe(sub_id) → bool: Cancel a subscription
  • add_message_callback(callback): Register a callback for all unsubscribed messages
  • close(): Shut down the connection
  • is_connected() → bool: Check connection status
  • client_id → str: The unique identifier for this connection
  • online_topic → str | None: The topic for liveness announcements (if configured)

See examples/pubsub.py for a complete working example.

Metadata

Release files for py-stinger-nng 0.1.1

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-nng 0.1.1
File Size Uploaded
py_stinger_nng-0.1.1.tar.gz 60.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-stinger-nng 0.1.1
File Interpreter ABI Platform
py_stinger_nng-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 72.4 kB

Release files / py_stinger_nng-0.1.1.tar.gz

Download URL py_stinger_nng-0.1.1.tar.gz
Size 60.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c5ca07062156c5e44193900e6d74b723c29ac4cc1075ea6b7c8ad8f658629c5b
BLAKE2b-256 checksum
How to use checksums
571d18181a7401798da2e894ff40302d34866ed61213e21f00a453d97c0a1e2a
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_nng-0.1.1-py3-none-any.whl

Download URL py_stinger_nng-0.1.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6459390aebb56be298a7d4eb8d5390bc0a5e215f495f7593e4c964dbd6f13f5e
BLAKE2b-256 checksum
How to use checksums
a2b69ee44df01ca11167084dac942a33442dae6e401f3038510e9df2cd18370d
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 history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release 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