# xq
A distributed queue system built on top of Redis
# install
```bash
pip3 install -r requirements.txt
```
# Use
## Producer
```python
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
```python
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
```python
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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/chishui/xq",
"name": "xqueue",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": null,
"keywords": "rq, queue, redis, messaging",
"author": "chishui",
"author_email": "chishui2@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3f/47/a69f886674f6e55c2d0291b7543a82e848c78b39cf538e813740a6f73c23/xqueue-0.0.1.tar.gz",
"platform": null,
"description": "# xq\nA distributed queue system built on top of Redis\n\n# install\n```bash\npip3 install -r requirements.txt\n```\n\n# Use\n## Producer\n```python\nimport redis\nfrom xq.queue import Queue\n\n# connect to Redis\nr = redis.Redis(host='localhost', port=6379)\n# create queue\nq = Queue(r, \"test_queue\")\n# enqueue\nq.enqueue(\"this is a message\")\n```\n\n## Consumer\n```python\nimport redis\nfrom xq.queue import Queue\n\n# connect to Redis\nr = redis.Redis(host='localhost', port=6379)\n# create queue\nq = Queue(r, \"test_queue\")\n# poll\nmessages = q.poll()\nfor message in messages:\n print(message.body)\n```\n\n## Use Worker\n```python\nimport redis\nfrom xq.queue import Queue\nfrom xq.worker import Worker\n\n# connect to Redis\nr = redis.Redis(host='localhost', port=6379)\n# create queue\nq = Queue(r, \"test_queue\")\nworker = Worker(q, process_message)\nworker.run()\n\ndef process_message(message):\n print(message)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A distributed messaging library similar to rq built on top of Redis",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/chishui/xq"
},
"split_keywords": [
"rq",
" queue",
" redis",
" messaging"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6eac20fee018b5f53cd72580470ba5a7f79f235c49daeaf4069fc0d3c07e167e",
"md5": "03e5123caba8bbe5c07e173c20b0daaf",
"sha256": "11aac209dd6a793035849ae4ad368bf14dce80674a98e9a228fc4b9ce9ae5241"
},
"downloads": -1,
"filename": "xqueue-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "03e5123caba8bbe5c07e173c20b0daaf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.8",
"size": 4553,
"upload_time": "2024-06-11T09:15:52",
"upload_time_iso_8601": "2024-06-11T09:15:52.772631Z",
"url": "https://files.pythonhosted.org/packages/6e/ac/20fee018b5f53cd72580470ba5a7f79f235c49daeaf4069fc0d3c07e167e/xqueue-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3f47a69f886674f6e55c2d0291b7543a82e848c78b39cf538e813740a6f73c23",
"md5": "87834c973f7a7156fe9423a43958dc9c",
"sha256": "ae5978624bb833cabc838d7e5b82119dafeccaec92d4c52ae454fcb96051845e"
},
"downloads": -1,
"filename": "xqueue-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "87834c973f7a7156fe9423a43958dc9c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 4628,
"upload_time": "2024-06-11T09:16:03",
"upload_time_iso_8601": "2024-06-11T09:16:03.228017Z",
"url": "https://files.pythonhosted.org/packages/3f/47/a69f886674f6e55c2d0291b7543a82e848c78b39cf538e813740a6f73c23/xqueue-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-11 09:16:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chishui",
"github_project": "xq",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "jsonpickle",
"specs": [
[
"==",
"3.0.2"
]
]
},
{
"name": "redis",
"specs": [
[
"==",
"5.0.1"
]
]
}
],
"lcname": "xqueue"
}