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
from tornado import web
from sprockets.mixins import amqp

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'})

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-0.1.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Supported by

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