Skip to content
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

Introduction of some wrappers/decorators. #22

Closed
wants to merge 5 commits into from

Conversation

funilrys
Copy link

This patch fix ##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
refer to the HealthCheck class, I made it clear that it is needed
as a reference. If it's not the intended behavior, let me know.

Note: It raises an exception if it gets 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
refer 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 gets an input class which is not
HealthCheck or EnvironmentDump.

What did I used to locally test?

from flask import Flask
from healthcheck import EnvironmentDump, HealthCheck, add_check_to, add_section_to

app = Flask(__name__)

health = HealthCheck()
envdump = EnvironmentDump()


# add your own check function to the healthcheck
@add_check_to(health)
def redis_available():
    client = _redis_client()
    info = client.info()
    return True, "redis ok"


# add your own data to the environment dump
@add_section_to(envdump, "application")
def application_data():
    return {
        "maintainer": "Luis Fernando Gomes",
        "git_repo": "https://github.com/ateliedocodigo/py-healthcheck",
    }


# Add a flask route to expose information
app.add_url_rule("/healthcheck", "healthcheck", view_func=lambda: health.run())
app.add_url_rule("/environment", "environment", view_func=lambda: envdump.run())

Hi there, I'm a bit late to the party but here is by #hacktoberfest contribution 😉

Cheers,
Nissar

funilrys and others added 5 commits October 30, 2019 09:41
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`.
Sorry, my previous commit was a stupidity 😭.
@funilrys funilrys closed this Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants