Pika plugin module for Bottle microframework
Project description
Bottle-Pika is a plugin that integrates Pika (AMQP) with your Bottle application. It automatically connects to AMQP at the beginning of a request, passes the channel to the route callback and closes the connection and channel afterwards.
To automatically detect routes that need a channel, the plugin searches for route callbacks that require a mq keyword argument (configurable) and skips routes that do not. This removes any overhead for routes that don’t need a message queue.
- This plugin was originally based on the bottle-mysql plugin found at:
Usage Example:
import bottle import bottle_pika import pika app = bottle.Bottle() pika_plugin = bottle_pika.Plugin(pika.URLParameters('amqp://localhost/')) app.install(pika_plugin) @app.route('/hello') def hello(mq): mq.basic_publish(...) return HTTPResponse(status=200)
- See pika documentation on channels for more information:
http://pika.readthedocs.org/en/latest/modules/channel.html#pika.channel.Channel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bottle_pika-0.1.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
bottle_pika-0.1.0-py2.7.egg
(5.0 kB
view hashes)