2014-10-13 15:16:28 +00:00
|
|
|
Examples
|
|
|
|
========
|
2014-10-14 16:16:12 +00:00
|
|
|
The following example demonstrates how to create a method that is invoked on
|
|
|
|
each call to ``/heartbeat`` in a web application.
|
2014-10-13 15:16:28 +00:00
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
2014-10-14 16:16:12 +00:00
|
|
|
from sprockets.handlers import heartbeat
|
|
|
|
from tornado import web
|
2014-10-13 15:16:28 +00:00
|
|
|
|
2014-10-14 16:16:12 +00:00
|
|
|
|
|
|
|
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)])
|