Skip to main content

Mixin for publishing events to RabbitMQ as avro datums

Project description

AMQP Publishing Mixin for publishing messages as Avro datum

Version Downloads

Installation

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

pip install sprockets.mixins.avro-publisher

Requirements

  • sprockets.mixins.amqp>=1.0.0

Example

This examples demonstrates the most basic usage of sprockets.mixins.avro-publisher

export AMQP_URL="amqp://user:password@rabbitmq_host:5672/%2f"
python my-example-app.py
from tornado import gen
from tornado import web
from sprockets.mixins import avro_publisher

def make_app(**settings):
    settings = {'avro_schema_uri_format': 'http://my-schema-repository/%(name)s.avsc'}
    application = web.Application(
        [
            web.url(r'/', RequestHandler),
        ], **settings)

    avro_publisher.install(application)
    return application

class RequestHandler(avro_publisher.AvroPublishingMixin, 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', body,
                                {'content_type': avro_publisher.DATUM_MIME_TYPE,
                                 'type': 'avro-schema-name'})

if __name__ == "__main__":
    application = make_app()
    application.listen(8888)
    logging.basicConfig(level=logging.INFO)
    ioloop.IOLoop.current().start()

Source

sprockets.mixins.avro-publisher source is available on Github at https://github.com/sprockets/sprockets.mixins.avro-publisher

License

sprockets.mixins.avro-publisher 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sprockets.mixins.avro_publisher-1.0.0-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for sprockets.mixins.avro_publisher-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc55e44411b4f37ef796ffa9a2257c9eabddb9286e3abcc4696b49a0be3b330f
MD5 ff1a6683517b6e10022571d974b5f71b
BLAKE2b-256 b55d1d8515695d0e3eab6d53789cecba1004434629b41245bfafd645021b29a2

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