-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a decorator #21
Labels
Comments
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 Flaskfrom 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()) Tornadoimport 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)),
]) |
funilrys
added a commit
to funilrys/py-healthcheck
that referenced
this issue
Oct 30, 2019
This patch fix #ateliedocodigo#21 What has been done? 1. Added the healthcheck/wrappers.py file/submodule. 2. Added the `wrappers.add_check_to` wrapper. 3. Added the `wrappers.add_section_to` wrapper. 4. Increased the version number into `setup.py`. About `wrappers.add_check_to`: As I do not want to create a global variable, or a unify the way to reference to the `HealthCheck` class, I made it clear that it is needed as reference. If it's not the intended behavior, let me know. Note: It raises an exception if it get an input class which is not `HealthCheck`. About `wrappers.add_section_to`: As I do not want to create a global variable, or unify the way we reference to `HealthCheck` or `EnvironmentDump`, I made it clear that one of them is needed. The second argument is the name of the section (nothing new). Note: It raises an exception if it get an input class which is not `HealthCheck` or `EnvironmentDump`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a decorator
@checker
in order to add checkers on other modules.The text was updated successfully, but these errors were encountered: