Upgrading to Newer Releases¶
This section of the documentation enumerates all the changes in gnsq from release to release and how you can change your code to have a painless updating experience.
Use the pip command to upgrade your existing Flask installation by
$ pip install --upgrade gnsq
While there are no breaking changes in version 1.0.0, much of the interface has been deprecated to both simplify the api and bring it into better compliance with the recommended naming schemes for nsq clients. Existing code should work as is and deprecation warnings will be emitted for any code paths that need to be changed.
The main interface has been renamed from
Consumer. The api remains largely the same and can be swapped out
directly in most cases.
max_concurrency parameter has been removed from
Consumer. If you wish to replicate this behavior, you should use
gnsq.contrib.QueueHandler in conjunction with a worker pool:
from gevent.pool import Pool from gnsq import Consumer from gnsq.contrib.queue import QueueHandler MAX_CONCURRENCY = 4 # Create your consumer as usual consumer = Consumer( 'topic', 'worker', 'localhost:4150', max_in_flight=16) # Connect a queue handler to the on message signal queue = QueueHandler() consumer.on_message.connect(queue) # Start your consumer without blocking or in a separate greenlet consumer.start(block=False) # If you want to limit your concurrency to a single greenlet, simply loop # over the queue in a for loop, or you can use a worker pool to distribute # the work. pool = Pool(MAX_CONCURRENCY) results = pool.imap_unordered(queue, my_handler) # Consume the results from the pool for result in results: pass
The methods publish_tcp, publish_http, multipublish_tcp, and multipublish_http have been removed from the new classes.