Metadata-Version: 2.1
Name: applipy-healthcheck
Version: 0.0.0
Summary: Exposes an http endpoint exposing the health status of the app
Home-page: https://gitlab.com/applipy/applipy_healthcheck
Author: Alessio Linares
Author-email: mail@alessio.cc
License: Apache 2.0
Project-URL: Source, https://gitlab.com/applipy/applipy_healthcheck
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: applipy-http (<2.0.0,>=1.0.0)

[![pipeline status](https://gitlab.com/applipy/applipy_healthcheck/badges/master/pipeline.svg)](https://gitlab.com/applipy/applipy_healthcheck/-/pipelines?scope=branches&ref=master)
[![coverage report](https://gitlab.com/applipy/applipy_healthcheck/badges/master/coverage.svg)](https://gitlab.com/applipy/applipy_healthcheck/-/graphs/master/charts)
[![PyPI Status](https://img.shields.io/pypi/status/applipy-healthcheck.svg)](https://pypi.org/project/applipy-healthcheck/)
[![PyPI Version](https://img.shields.io/pypi/v/applipy-healthcheck.svg)](https://pypi.org/project/applipy-healthcheck/)
[![PyPI Python](https://img.shields.io/pypi/pyversions/applipy-healthcheck.svg)](https://pypi.org/project/applipy-healthcheck/)
[![PyPI License](https://img.shields.io/pypi/l/applipy-healthcheck.svg)](https://pypi.org/project/applipy-healthcheck/)
[![PyPI Format](https://img.shields.io/pypi/format/applipy-healthcheck.svg)](https://pypi.org/project/applipy-healthcheck/)

# Applipy HealthCheck Metrics

    pip install applipy_healthcheck

Exposes the health status of the applipy application through an HTTP endpoint with path `/health`.

## Usage

Add the `applipy_healthcheck.HealthCheckModule` to your application. Optionally,
define through which http server to expose the `/health` endpoint, if no name
is given it defaults to the anonymous server:

```yaml
# dev.yaml

app:
    name: demo
    modules:
        - applipy_healthcheck.HealthCheckModule

http:
    internal:
        host: 0.0.0.0
        port: 8080

healthcheck.server_name: internal
```

To run this test just install `applipy_healthcheck` and `pyyaml` and run the applipy application:

```bash
pip install applipy_healthcheck pyyaml
python -m applipy
```

You can now query [http://0.0.0.0:8080/health](http://0.0.0.0:8080/health)
and you should see `OK` being returned.

## Custom health checks

`applipy_healthcheck` exposes the `HealthChecker` interface. You can implement
your own and the health check endpoint will use it to determine the health of
the system.

### Example

#### Full healthcheck module config

All keys and their default values:

```yaml
healthcheck:
  server_name: null
  verbose: false
```

#### Usage with custom HealthChecker

```python
# mymodule.py

from applipy import Module
from applipy_healthcheck import HealthChecker


class MyHealthChecker(HealthChecker):

    async def check(self):
        is_healthy = True
        status_message = 'All OK'
        return is_healthy, status_message


class MyModule(Module):
    def configure(self, bind, register):
        bind(HealthChecker, MyHealthChecker)

    @classmethod
    def depends_on(cls):
        return HealthCheckModule,
```

```yaml
# dev.yaml

app:
  name: test
  modules: [mymodule.MyModule]

http:
  host: 0.0.0.0
  port: 8080
```


