py-healthcheck
py-healthcheck copied to clipboard
Create a decorator
Create a decorator @checker
in order to add checkers on other modules.
Note: keep in mind that this package supports
flask
endtornado
I want to have look at this one. Is interface like this ok?
@checker(health: HealthCheck)
def example_checker():
...
No, it should be like this
Flask
from flask import Flask
from healthcheck import checker, HealthCheck
app = Flask(__name__)
health = HealthCheck()
# add your own check function to the healthcheck
@checker
def redis_available():
client = _redis_client()
info = client.info()
return True, "redis ok"
# Add a flask route to expose information
app.add_url_rule("/healthcheck", "healthcheck", view_func=lambda: health.run())
Tornado
import tornado.web
from healthcheck import checker, TornadoHandler, HealthCheck
# add your own check function to the healthcheck
@checker
def redis_available():
client = _redis_client()
info = client.info()
return True, "redis ok"
health = HealthCheck()
app = tornado.web.Application([
("/healthcheck", TornadoHandler, dict(checker=health)),
])