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.1.0.tar.gz (10.5 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.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for redqlite-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ecc4999dfb699b03ede5a79f5f599867e35eaf7871c74cc3c407a25f0c4a4ce3
MD5 b7ccabc391c8edc7eb01c1ac6ff80104
BLAKE2b-256 82129d187fe6346e2fd709d39fcdbd518ce07a140a4c5f4a117ea5bd62c4154a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redqlite-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 312f9ba0872c2b2776ff718e510fd383c810e7af44081bd8cfadad47db371792
MD5 0f2e489b7862e3daa4f28422f5d378c6
BLAKE2b-256 ee88b87b12cd2b6110c872a7d1a56c5c43bafa15ac903d797f596a21496433c6

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