django-healthpoint


Namedjango-healthpoint JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttp://github.com/pennersr/django-healthpoint
SummaryEasily create an endpoint for health checks
upload_time2024-03-05 10:36:02
maintainer
docs_urlNone
authorRaymond Penners
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            ==============================
Welcome to django-healthpoint!
==============================

.. image:: https://badge.fury.io/py/django-healthpoint.png
   :target: http://badge.fury.io/py/django-healthpoint

.. image:: https://github.com/pennersr/django-healthpoint/actions/workflows/ci.yml/badge.svg
   :target: https://github.com/pennersr/django-healthpoint/actions

.. image:: https://img.shields.io/pypi/v/django-healthpoint.svg
   :target: https://pypi.python.org/pypi/django-healthpoint

.. image:: https://coveralls.io/repos/pennersr/django-healthpoint/badge.png?branch=main
   :alt: Coverage Status
   :target: https://coveralls.io/r/pennersr/django-healthpoint

.. image:: https://pennersr.github.io/img/bitcoin-badge.svg
   :target: https://blockchain.info/address/1AJXuBMPHkaDCNX2rwAy34bGgs7hmrePEr

.. image:: https://pennersr.github.io/img/emacs-badge.svg
   :target: https://www.gnu.org/software/emacs/

Framework for adding an endpoint for health checks to your project.

Source code
  http://github.com/pennersr/django-healthpoint


Quickstart
==========

Install the app::

    # settings.py
    INSTALLED_APPS = [
        ...
        'healthpoint'
    ]

    # If specified, this user is able to see the details for each
    # individual check in the endpoint.
    HEALTHPOINT_BASICAUTH_USERNAME = 'john'
    HEALTHPOINT_BASICAUTH_PASSWORD = 'doe'

    # If set to True authentication is required for executing the
    # health checks.
    HEALTHPOINT_AUTH_REQUIRED = True

    # urls.py
    urlpatterns = [
        ...
        url(r'^', include('healthpoint.urls')),
    ]

Add a module named ``health.py`` to any of your apps. For example::

    from datetime import timedelta

    from django.contrib.auth.models import User
    from django.utils import timezone

    from healthpoint.decorators import health_check


    @health_check
    def user_signup():
        last_user = User.objects.last()
        time_since_last_signup = timezone.now() - last_user.date_joined
        # Return True/False, throw an exception, or return a tuple with a
        # detail message.
        return (
            time_since_last_signup <= timedelta(days=1),
            "last signup was: {}".format(last_user.date_joined))


The health checks can be accessed via the ``/health/`` endpoint:

- It executes all health checks, and reports status 200 if all checks succeed, status 500 otherwise.

- If a staff user is logged in, the endpoint reports the result for each individual check::

    {
     "success": {},
     "error": {
       "myproject.myapp.health.user_signup": "Last signup was: 2017-10-29 08:45:51"
     }
    }

- To provide more detail on the result, the ``@health_check`` can return a tuple ``(success:bool, detail:str)``. The detail message will be listed in the result.

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/pennersr/django-healthpoint",
    "name": "django-healthpoint",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Raymond Penners",
    "author_email": "raymond.penners@intenct.nl",
    "download_url": "https://files.pythonhosted.org/packages/aa/60/6171b18404c1937da73dae899a5dabd099dee24c2743a133ae9384ed5843/django-healthpoint-1.0.0.tar.gz",
    "platform": "any",
    "description": "==============================\nWelcome to django-healthpoint!\n==============================\n\n.. image:: https://badge.fury.io/py/django-healthpoint.png\n   :target: http://badge.fury.io/py/django-healthpoint\n\n.. image:: https://github.com/pennersr/django-healthpoint/actions/workflows/ci.yml/badge.svg\n   :target: https://github.com/pennersr/django-healthpoint/actions\n\n.. image:: https://img.shields.io/pypi/v/django-healthpoint.svg\n   :target: https://pypi.python.org/pypi/django-healthpoint\n\n.. image:: https://coveralls.io/repos/pennersr/django-healthpoint/badge.png?branch=main\n   :alt: Coverage Status\n   :target: https://coveralls.io/r/pennersr/django-healthpoint\n\n.. image:: https://pennersr.github.io/img/bitcoin-badge.svg\n   :target: https://blockchain.info/address/1AJXuBMPHkaDCNX2rwAy34bGgs7hmrePEr\n\n.. image:: https://pennersr.github.io/img/emacs-badge.svg\n   :target: https://www.gnu.org/software/emacs/\n\nFramework for adding an endpoint for health checks to your project.\n\nSource code\n  http://github.com/pennersr/django-healthpoint\n\n\nQuickstart\n==========\n\nInstall the app::\n\n    # settings.py\n    INSTALLED_APPS = [\n        ...\n        'healthpoint'\n    ]\n\n    # If specified, this user is able to see the details for each\n    # individual check in the endpoint.\n    HEALTHPOINT_BASICAUTH_USERNAME = 'john'\n    HEALTHPOINT_BASICAUTH_PASSWORD = 'doe'\n\n    # If set to True authentication is required for executing the\n    # health checks.\n    HEALTHPOINT_AUTH_REQUIRED = True\n\n    # urls.py\n    urlpatterns = [\n        ...\n        url(r'^', include('healthpoint.urls')),\n    ]\n\nAdd a module named ``health.py`` to any of your apps. For example::\n\n    from datetime import timedelta\n\n    from django.contrib.auth.models import User\n    from django.utils import timezone\n\n    from healthpoint.decorators import health_check\n\n\n    @health_check\n    def user_signup():\n        last_user = User.objects.last()\n        time_since_last_signup = timezone.now() - last_user.date_joined\n        # Return True/False, throw an exception, or return a tuple with a\n        # detail message.\n        return (\n            time_since_last_signup <= timedelta(days=1),\n            \"last signup was: {}\".format(last_user.date_joined))\n\n\nThe health checks can be accessed via the ``/health/`` endpoint:\n\n- It executes all health checks, and reports status 200 if all checks succeed, status 500 otherwise.\n\n- If a staff user is logged in, the endpoint reports the result for each individual check::\n\n    {\n     \"success\": {},\n     \"error\": {\n       \"myproject.myapp.health.user_signup\": \"Last signup was: 2017-10-29 08:45:51\"\n     }\n    }\n\n- To provide more detail on the result, the ``@health_check`` can return a tuple ``(success:bool, detail:str)``. The detail message will be listed in the result.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Easily create an endpoint for health checks",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "http://github.com/pennersr/django-healthpoint"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa606171b18404c1937da73dae899a5dabd099dee24c2743a133ae9384ed5843",
                "md5": "de3e0ce6180e412de14da8f0e132f4d9",
                "sha256": "f3bca2452d3f5fc9c8baa9a82e723b0cddcfd7ca00747041ebe24583c415ccdb"
            },
            "downloads": -1,
            "filename": "django-healthpoint-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "de3e0ce6180e412de14da8f0e132f4d9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7024,
            "upload_time": "2024-03-05T10:36:02",
            "upload_time_iso_8601": "2024-03-05T10:36:02.584655Z",
            "url": "https://files.pythonhosted.org/packages/aa/60/6171b18404c1937da73dae899a5dabd099dee24c2743a133ae9384ed5843/django-healthpoint-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 10:36:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pennersr",
    "github_project": "django-healthpoint",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "django-healthpoint"
}
        
Elapsed time: 0.21374s