Skip to main content

A lightweight Messaging queue implementation using Redis for producer-worker-subscriber messaging.

Project description

RedQLite

A lightweight Messaging queue implementation using Redis for producer-worker-subscriber messaging.


Features

  • Redis-backed message queuing
  • Producer and worker interface
  • Producer and subscriber interface
  • Lightweight and fast alternative to Kafka/Celery
  • Works for long running tasks
  • Provides configurable heartbeats from inside worker callback functions
  • Redis server required
  • Minimal setup — no broker required

Installation

pip install redqlite

How It Works

This package simulates a basic messaging system using Redis lists. It includes:

A Producer that pushes messages to a Redis queue or broadcasts messages to all subscribers.

A Worker that consumes messages from the queue and processes them.

A Worker Pool to run concurrent workers.

A Subscriber that consumes messages from channel specific message queue.

Usage

Example: Producing a Message

# Import RQProducer class
from redqlite.producer import RQProducer

# Create a producer instance
rqproducer = RQProducer(host="localhost", port=6379)

# Send a message
rqproducer.send(topic="yourtopicname", message="hello world")

# Broadcast message on a channel
rqproducer.broadcast(channel="yourchannelname", message="hello world")

Example: Starting a Worker

# Import RQWorker class
from redqlite.worker import RQWorker

def callback_func(msg, **kwargs):
	print(msg)

# Create a worker instance
## Provide your redis connection details or Redis connection pool object
rqworker = RQWorker(host="localhost", port=6379, topic="yourtopicname", callback=callback_func)

# Start worker thread
rqworker.start()

Example: Starting a Worker Pool

# Import RQWorkerPool class
from redqlite.worker import RQWorkerPool

def callback_func(msg, **kwargs):
	print(msg)

# Create a worker pool
## Provide your redis connection details or Redis connection pool object
rqworker_pool = RQWorkerPool(host="localhost", port=6379, topic="yourtopicname", callback=callback_func, num_workers=2)

# Start worker pool
rqworker_pool.start()

Example: Starting a subscriber

# Import QSubscriber class
from redqlite.subscriber import RQSubscriber
from redis import Redis

def callback_func(msg, **kwargs):
	print(msg)

# Create a worker instance
rqsubscriber = RQSubscriber(redis_conn=Redis(), channel="yourchannelname", callback=callback_func)

# Start subscriber thread
rqsubscriber.start()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you’d like to change.

Contact

Feel free to reach out by opening an issue or by contacting the author.

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

redqlite-1.2.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

redqlite-1.2.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file redqlite-1.2.0.tar.gz.

File metadata

  • Download URL: redqlite-1.2.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for redqlite-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2cfa3c288e276b645c416da4c3bcd67d23d6f95868a0b920a16641f2a08729d8
MD5 3038f3a4049ee64cc641518ee8231fd9
BLAKE2b-256 8f2e6b40353974d22b7a7c09479351006f0e583c8cae0a441c2620be7bcc32e2

See more details on using hashes here.

File details

Details for the file redqlite-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: redqlite-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for redqlite-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fff52a03e36faeec8285490f1879e562187764ad221e5f192be3872fea435b1d
MD5 6d01b02214a544f5cb84c11f8566328f
BLAKE2b-256 697d9bb3b64ffd82cf922ea0cb8028bd524dc70887e6600c7371fd0a95470fbe

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