2014-10-13 15:16:28 +00:00
|
|
|
sprockets.handlers.heartbeat
|
|
|
|
============================
|
|
|
|
A callback-based heartbeat handler
|
|
|
|
|
|
|
|
|Version| |Downloads| |Status| |Coverage| |License|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
``sprockets.handlers.heartbeat`` is available on the
|
|
|
|
`Python Package Index <https://pypi.python.org/pypi/sprockets.handlers.heartbeat>`_
|
|
|
|
and can be installed via ``pip`` or ``easy_install``:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
pip install sprockets.handlers.heartbeat
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
-------------
|
|
|
|
https://sprocketshandlersheartbeat.readthedocs.org
|
|
|
|
|
|
|
|
Requirements
|
|
|
|
------------
|
2014-10-14 16:16:12 +00:00
|
|
|
- `tornado <https://github.com/tornadoweb/tornado>`_
|
2014-10-13 15:16:28 +00:00
|
|
|
|
|
|
|
Example
|
|
|
|
-------
|
2014-10-14 16:16:12 +00:00
|
|
|
This examples demonstrates how to use ``sprockets.handlers.heartbeat`` by
|
|
|
|
registering the ``check_database`` method that is invoked each time a request
|
|
|
|
to ``/heartbeat`` is made.
|
2014-10-14 15:48:28 +00:00
|
|
|
|
2014-10-13 15:16:28 +00:00
|
|
|
.. code:: python
|
|
|
|
|
2014-10-14 16:16:12 +00:00
|
|
|
from sprockets.handlers import heartbeat
|
2014-10-13 17:36:19 +00:00
|
|
|
from tornado import web
|
|
|
|
|
2014-10-13 15:16:28 +00:00
|
|
|
|
2014-10-13 17:36:19 +00:00
|
|
|
def check_database():
|
2014-10-14 16:16:12 +00:00
|
|
|
"""Any check method should return a bool specifying the check is ok.
|
|
|
|
|
|
|
|
:rtype: bool
|
|
|
|
|
|
|
|
"""
|
|
|
|
return True
|
2014-10-13 17:36:19 +00:00
|
|
|
|
2014-10-14 16:16:12 +00:00
|
|
|
# Register the check method
|
2014-10-14 15:48:28 +00:00
|
|
|
heartbeat.register_callback(check_database)
|
2014-10-13 17:36:19 +00:00
|
|
|
|
2014-10-14 16:16:12 +00:00
|
|
|
# Create a Tornado application
|
|
|
|
app = web.Application([('/heartbeat', heartbeat.HeartbeatHandler)])
|
2014-10-13 15:16:28 +00:00
|
|
|
|
|
|
|
Version History
|
|
|
|
---------------
|
|
|
|
Available at https://sprocketshandlersheartbeat.readthedocs.org/en/latest/history.html
|
|
|
|
|
|
|
|
.. |Version| image:: https://badge.fury.io/py/sprockets.handlers.heartbeat.svg?
|
|
|
|
:target: http://badge.fury.io/py/sprockets.handlers.heartbeat
|
|
|
|
|
|
|
|
.. |Status| image:: https://travis-ci.org/sprockets/sprockets.handlers.heartbeat.svg?branch=master
|
|
|
|
:target: https://travis-ci.org/sprockets/sprockets.handlers.heartbeat
|
|
|
|
|
|
|
|
.. |Coverage| image:: https://img.shields.io/coveralls/sprockets/sprockets.handlers.heartbeat.svg?
|
|
|
|
:target: https://coveralls.io/r/sprockets/sprockets.handlers.heartbeat
|
|
|
|
|
|
|
|
.. |Downloads| image:: https://pypip.in/d/sprockets.handlers.heartbeat/badge.svg?
|
|
|
|
:target: https://pypi.python.org/pypi/sprockets.handlers.heartbeat
|
|
|
|
|
|
|
|
.. |License| image:: https://pypip.in/license/sprockets.handlers.heartbeat/badge.svg?
|
2014-10-13 17:36:19 +00:00
|
|
|
:target: https://sprocketshandlersheartbeat.readthedocs.org
|