跳转到主要内容

基于Redis的分布式消息队列

项目描述

Styx是一个简单的库,可以将多个独立的Redis服务器转换为一个强大的分布式队列。Redis服务器无需任何特殊配置,也不需要以任何方式相互了解。消息是松散排序的。可以在这里找到Java版本。Java和Python版本是兼容的 - 即一个客户端发布的消息可以被另一个客户端读取。

安装

pip install styx

快速入门

#!/usr/bin/env python
# encoding: utf-8

import styx

# Define the Redis host locations (the default port is 6379)
hosts = [ "redis1.example.com", "redis2.example.com:8080", "redis3.example.com" ]

connection = styx.Styx(hosts, db=3) # default db is 0
# If a queue doesn't exist, it will be created automatically
q = connection.get_queue("myTestQueue")
q.put("Hello")
q.put("World")
q.put("Message1234")

q.get() # returns "Hello"
q.get() # returns "World"

# Check how many messages are left in the queue
q.size() # returns 1

# Delete this queue
connection.delete_queue(q)

单元测试

要运行单元测试,请确保您在本地主机上以6700、6701、6702端口运行3个Redis实例。

pip install nose
nosetests

源代码在GitHub上可用: http://github.com/abh1nav/styx-python/

项目详情


下载文件

下载适合您平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

styx-0.1.2.tar.gz (3.5 kB 查看哈希)

源代码

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面