Skip to main content

Mixin for publishing events to RabbitMQ

Project description

AMQP Publishing Mixin for Tornado RequestHandlers.

Version Downloads Travis CodeCov ReadTheDocs

Installation

sprockets.mixins.amqp is available on the Python Package Index and can be installed via pip or easy_install:

pip install sprockets.mixins.amqp

Documentation

https://sprocketsamqp.readthedocs.org

Requirements

  • pika>=0.10.0

  • tornado>=4.2.0

Example

This examples demonstrates the most basic usage of sprockets.mixins.amqp

export AMQP_URL="amqp://user:password@rabbitmq_host:5672/%2f"
python my-example-app.py
 import json

 from tornado import gen, web
 from sprockets.mixins import amqp

def make_app(**settings):
     application = web.Application(
         [
             web.url(r'/', RequestHandler),
         ], **settings)

     amqp.install(application)
     return application


 class RequestHandler(amqp.PublishingMixin, web.RequestHandler):

     @gen.coroutine
     def get(self, *args, **kwargs):
         body = {'request': self.request.path, 'args': args, 'kwargs': kwargs}
         yield self.amqp_publish('exchange', 'routing.key', json.dumps(body),
                                 {'content_type': 'application/json'})

Settings

url:

The AMQP url

timeout:

The connect timeout, in seconds, if the connection when you try to publish.

connection_attempts:

The maximum number of retry attempts in case of connection errors.

Source

sprockets.mixins.amqp source is available on Github at https://github.com/sprockets/sprockets.mixins.amqp

License

sprockets.mixins.amqp is released under the 3-Clause BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sprockets.mixins.amqp-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sprockets.mixins.amqp-1.0.0-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sprockets.mixins.amqp-1.0.0.tar.gz.

File metadata

File hashes

Hashes for sprockets.mixins.amqp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b5eea695d5996769d5f3e7dcefb5387f12a20780ee48fc7286aec73f09288d84
MD5 2e41454f23b1817b90d483bc59971c7a
BLAKE2b-256 ef3e3c3cda38fe5a038fe5865a0ad9c6fde72e9493995ac7da3af6984f45e574

See more details on using hashes here.

File details

Details for the file sprockets.mixins.amqp-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sprockets.mixins.amqp-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f4947445af413b10886c276992daf6d4f8317cdf56b285769e638b9b4ce6d8f5
MD5 ba9e6f386b405e51b8fbc61158795893
BLAKE2b-256 fdb6fb8a4ce5a456f06e6a2826c64352b449026f1032a37294366b74c831e5cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page