sprockets.handlers.heartbeat¶
A callback-based heartbeat handler
Installation¶
sprockets.handlers.heartbeat is available on the Python Package Index and can be installed via pip or easy_install:
pip install sprockets.handlers.heartbeat
API Documentation¶
handlers.heartbeat
A callback-based heartbeat handler
- class sprockets.handlers.heartbeat.HeartbeatHandler(application, request, **kwargs)¶
Heartbeat handler to determine if a service is healthy.
- get()¶
Respond with the health of our service.
- sprockets.handlers.heartbeat.register_callback(callable_)¶
Register a callable to be checked during heartbeat.
This function adds a new heartbeat callback, which can be any callable that returns True if healthy, and False if it detects a problem. Any False return value will cause a call to the HeartbeatHandler to return a 500.
Examples¶
The following example demonstrates how to create a method that is invoked on each call to /heartbeat in a web application.
from sprockets.handlers import heartbeat
from tornado import web
def check_database():
"""Any check method should return a bool specifying the check is ok.
:rtype: bool
"""
return True
# Register the check method
heartbeat.register_callback(check_database)
# Create a Tornado application
app = web.Application([('/heartbeat', heartbeat.HeartbeatHandler)])
Version History¶
See Version History
Issues¶
Please report any issues to the Github project at https://github.com/sprockets/sprockets.handlers.heartbeat/issues
Source¶
sprockets.handlers.heartbeat source is available on Github at https://github.com/sprockets/sprockets.handlers.heartbeat
License¶
sprockets.handlers.heartbeat is released under the 3-Clause BSD license.