Skip to main content

A publish-subscribe messaging system

Project description

PubSubX

PubSubX is a lightweight publish-subscribe messaging system implemented in Python. It provides a simple server and client for building distributed messaging applications.

Installation

You can install PubSubX using pip:

pip install pubsubx

Usage

Starting the server

There are multiple ways to start the PubSubX server:

  1. As a module:

    python -m pubsubx [--host HOST] [--port PORT]
    
  2. Using the console script:

    pubsubx [--host HOST] [--port PORT]
    
  3. In your Python code:

    from pubsubx import PubSubServer
    
    server = PubSubServer(host='localhost', port=5000)
    server.start()
    

The default host is 'localhost' and the default port is 5000.

Using the client

Here's a simple example of how to use the PubSubX client:

from pubsubx import PubSubClient
import time

def on_message(topic, message):
    print(f"Received message on topic '{topic}': {message}")

# Create and connect the client
client = PubSubClient()
client.connect()

# Set up the message callback
client.on_message(on_message)

# Subscribe to a topic
client.subscribe("test_topic")

# Publish a message
client.publish("test_topic", "Hello, PubSubX!")

# Keep the script running
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Disconnecting...")
    client.disconnect()

License

This project is licensed under the MIT License.

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

pubsubx-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

pubsubx-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pubsubx-0.1.2.tar.gz.

File metadata

  • Download URL: pubsubx-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pubsubx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dc20606ad03aa290f94f12ba39305fc667a327bff205a620c4d06f6591723b4f
MD5 3d2beef31a32d0b4cf071a4035dcca1c
BLAKE2b-256 e28241c8a0f02d91fc839fbb34dc401fbcf8f17722b188f71fcd69692404cc89

See more details on using hashes here.

File details

Details for the file pubsubx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pubsubx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pubsubx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd70a980d9400ca1929e0bbc88062f048b6db7625a7760f25c0a20ab1a2d9dd3
MD5 507145cfc060c33a67c178c960166a12
BLAKE2b-256 e63e7e0bd4c9ac2e0162f82f84f2688d013df79b2d37ea40228122dc09507882

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