2015-09-24 19:02:32 +00:00
sprockets.mixins.avro-publisher
2015-09-24 18:29:18 +00:00
===============================
2017-04-13 21:13:22 +00:00
AMQP Publishing Mixin for publishing a message as an Avro datum.
2015-09-24 18:29:18 +00:00
2015-09-24 19:02:32 +00:00
|Version| |Downloads|
2015-09-24 18:29:18 +00:00
Installation
------------
2015-09-24 19:02:32 +00:00
`` sprockets.mixins.avro-publisher `` is available on the
`Python Package Index <https://pypi.python.org/pypi/sprockets.mixins.avro-publisher> `_
2015-09-24 18:29:18 +00:00
and can be installed via `` pip `` or `` easy_install `` :
.. code-block :: bash
2015-09-24 19:09:34 +00:00
pip install sprockets.mixins.avro-publisher
2015-09-24 18:29:18 +00:00
Requirements
------------
2020-03-16 11:12:35 +00:00
- sprockets.mixins.amqp>=3.0.0
2017-04-13 21:13:22 +00:00
- fastavro>=0.10.1,<1.0.0
2020-03-16 11:12:35 +00:00
- tornado>=6,<7
2015-09-24 18:29:18 +00:00
Example
-------
2015-09-24 19:02:32 +00:00
This examples demonstrates the most basic usage of `` sprockets.mixins.avro-publisher ``
2015-09-24 18:29:18 +00:00
.. code :: bash
export AMQP_URL="amqp://user:password@rabbitmq_host:5672/%2f"
python my-example-app.py
.. code :: python
from tornado import gen
from tornado import web
from sprockets.mixins import avro_publisher
2016-03-15 17:53:46 +00:00
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
2017-04-13 21:13:22 +00:00
class RequestHandler(avro_publisher.PublishingMixin, web.RequestHandler):
2015-09-24 18:29:18 +00:00
2020-03-16 11:12:35 +00:00
async def get(self, *args, * *kwargs):
2015-09-24 18:29:18 +00:00
body = {'request': self.request.path, 'args': args, 'kwargs': kwargs}
2020-03-16 11:12:35 +00:00
await self.avro_amqp_publish(
2017-04-13 21:13:22 +00:00
'exchange',
'routing.key',
'avro-schema-name'
body)
2015-09-24 18:29:18 +00:00
if __name__ == "__main__":
2016-03-15 17:53:46 +00:00
application = make_app()
2015-09-24 18:29:18 +00:00
application.listen(8888)
logging.basicConfig(level=logging.INFO)
ioloop.IOLoop.current().start()
Source
------
2015-09-24 19:02:32 +00:00
`` sprockets.mixins.avro-publisher `` source is available on Github at `https://github.com/sprockets/sprockets.mixins.avro-publisher <https://github.com/sprockets/sprockets.mixins.avro_publisher> `_
2015-09-24 18:29:18 +00:00
License
-------
2015-09-24 19:02:32 +00:00
`` sprockets.mixins.avro-publisher `` is released under the `3-Clause BSD license <https://github.com/sprockets/sprockets.mixins.avro-publisher/blob/master/LICENSE> `_ .
2015-09-24 18:29:18 +00:00
2015-09-24 19:02:32 +00:00
.. |Version| image :: https://badge.fury.io/py/sprockets.mixins.avro-publisher.svg?
:target: http://badge.fury.io/py/sprockets.mixins.avro-publisher
2015-09-24 18:29:18 +00:00
2015-09-24 19:02:32 +00:00
.. |Downloads| image :: https://pypip.in/d/sprockets.mixins.avro-publisher/badge.svg?
:target: https://pypi.python.org/pypi/sprockets.mixins.avro-publisher