Skip to content

msaUtils Module

.healthcheck


Classes

MSAHealthCheck

Bases: Thread

Attributes

error instance-attribute
error: str = ''
healthy instance-attribute
healthy: str = 'No Healthcheck executed yet:400'
interval instance-attribute
interval = healthdefinition.interval
is_healthy instance-attribute
is_healthy: bool = False
url instance-attribute
url = 'http://{}:{}/'.format(host, port)

Functions

__init__
__init__(
    healthdefinition: MSAHealthDefinition,
    host: str,
    port: int,
)

MSAHealthCheckObject, provides a thread to give a healthcheck.

PARAMETER DESCRIPTION
healthdefinition

The MSAHealthDefinition instance

TYPE: MSAHealthDefinition

host

IP/URl to call the healtcheck endpoint

TYPE: str

port

Port of the healtcheck endpoint server listener/endpoint

TYPE: int

get_health async
get_health() -> str

Get the last health check result

The string is "positiv: status_code" or "negative: status_code"

run
run()

Run the Healthcheck Thread

Sleeps by the interval provided by the MSAHealthDefinition.

Uses httpx to call the healthcheck endpoint which is http://{}:{}/".format(host, port)

Any 200 <= response.status_code < 300 is healthy, rest is not healthy

stop async
stop()

Stops the Healthcheck Thread.


Last update: September 24, 2022
Created: September 24, 2022