Welcome to gnsq’s documentation!¶
gnsq¶
A gevent based python client for NSQ distributed messaging platform.
Features include:
- Free software: BSD license
- Documentation: https://gnsq.readthedocs.org
- Battle tested on billions and billions of messages </sagan>
- Based on gevent for fast concurrent networking
- Fast and flexible signals with Blinker
- Automatic nsqlookupd discovery and back-off
- Support for TLS, DEFLATE, and Snappy
- Full HTTP clients for both nsqd and nsqlookupd
Installation¶
At the command line:
$ easy_install gnsq
Or even better, if you have virtualenvwrapper installed:
$ mkvirtualenv gnsq
$ pip install gnsq
Currently there is support for Python 2.7+, Python 3.4+ and PyPy.
Usage¶
First make sure nsq is installed and running. Next create a producer and publish some messages to your topic:
import gnsq
producer = gnsq.Producer('localhost:4150')
producer.start()
producer.publish('topic', 'hello gevent!')
producer.publish('topic', 'hello nsq!')
Then create a Consumer to consume messages from your topic:
consumer = gnsq.Consumer('topic', 'channel', 'localhost:4150')
@consumer.on_message.connect
def handler(consumer, message):
print 'got message:', message.body
consumer.start()
Compatibility¶
For NSQ 1.0 and later, use the major version 1 (1.x.y
) of gnsq.
For NSQ 0.3.8 and earlier, use the major version 0 (0.x.y
) of the
library.
The recommended way to set your requirements in your setup.py or requirements.txt is:
# NSQ 1.x.y
gnsq>=1.0.0
# NSQ 0.x.y
gnsq<1.0.0
Dependencies¶
Optional snappy support depends on the python-snappy package which in turn depends on libsnappy:
# Debian
$ sudo apt-get install libsnappy-dev
# Or OS X
$ brew install snappy
# And then install python-snappy
$ pip install python-snappy
Contributing¶
Feedback, issues, and contributions are always gratefully welcomed. See the contributing guide for details on how to help and setup a development environment.
Contents¶
- Consumer: high-level message reader
- Producer: high-level message writer
- Nsqd clients
- Nsqlookupd client
- NSQ Message
- Signals
- Contrib modules
- Contributing
- Credits
- Upgrading to Newer Releases
- History
- 1.0.1 (2019-04-24)
- 1.0.0 (2019-04-24)
- 0.4.0 (2017-06-13)
- 0.3.3 (2016-09-25)
- 0.3.2 (2016-04-10)
- 0.3.1 (2015-11-06)
- 0.3.0 (2015-06-14)
- 0.2.3 (2015-02-16)
- 0.2.2 (2015-01-12)
- 0.2.1 (2015-01-12)
- 0.2.0 (2014-08-03)
- 0.1.4 (2014-07-24)
- 0.1.3 (2014-07-08)
- 0.1.2 (2014-07-08)
- 0.1.1 (2014-07-07)
- 0.1.0 (2014-07-07)