Skip to content
/ xq Public

A distributed queue system built on top of Redis

License

Notifications You must be signed in to change notification settings

chishui/xq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xq

A distributed queue system built on top of Redis

install

pip3 install -r requirements.txt

Use

Producer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# enqueue
q.enqueue("this is a message")

Consumer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# poll
messages = q.poll()
for message in messages:
    print(message.body)

Use Worker

import redis
from xq.queue import Queue
from xq.worker import Worker

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
worker = Worker(q, process_message)
worker.run()

def process_message(message):
    print(message)

About

A distributed queue system built on top of Redis

Resources

License

Stars

Watchers

Forks

Packages

No packages published