All Projects → Kludex → fastapi-health

Kludex / fastapi-health

Licence: MIT license
Implement the Health Check API pattern on your FastAPI application! 🚀

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to fastapi-health

ping
A WAR Ping For JavaEE 7 Application Servers
Stars: ✭ 51 (-53.64%)
Mutual labels:  healthcheck
fastapi
基于Fastapi开发,集成Celery-redis分布式任务队列、JWT 用户系统、ElasticSearch和encode orm的基础项目模板,大家可以根据自己的需求在本模板上进行修改
Stars: ✭ 75 (-31.82%)
Mutual labels:  fastapi
openapi-python-client
Generate modern Python clients from OpenAPI
Stars: ✭ 543 (+393.64%)
Mutual labels:  fastapi
SetuAPI
色图API
Stars: ✭ 39 (-64.55%)
Mutual labels:  fastapi
fastapi-mysql-generator
FastAPI + MySQL Web项目生成器 ,个人认为较为合理的项目组织结构;基于apscheduler的定时任务。
Stars: ✭ 348 (+216.36%)
Mutual labels:  fastapi
chip
📦 🐳 🚀 - Smart "dummy" mock for cloud native tests
Stars: ✭ 19 (-82.73%)
Mutual labels:  healthcheck
sickbay
Get the HTTP status of a bunch of URLs in a single JSON response. Ideal for monitoring a lot of services at once.
Stars: ✭ 19 (-82.73%)
Mutual labels:  healthcheck
fastapi-celery-redis-rabbitmq
A simple docker-compose app for orchestrating a fastapi application, a celery queue with rabbitmq(broker) and redis(backend)
Stars: ✭ 81 (-26.36%)
Mutual labels:  fastapi
KivyMLApp
The repository host the API for the ML model via FastAPI, Flask and contains android app development files using KivyMD.
Stars: ✭ 54 (-50.91%)
Mutual labels:  fastapi
Voice4Rural
A complete one stop solution for all the problems of Rural area people. 👩🏻‍🌾
Stars: ✭ 12 (-89.09%)
Mutual labels:  fastapi
rfc-healthcheck
Health Check Response RFC Draft for HTTP APIs
Stars: ✭ 110 (+0%)
Mutual labels:  healthcheck
ml gallery
This is a master project of some experiments with Neural Networks. Every project here is runnable, visualized and explained clearly.
Stars: ✭ 18 (-83.64%)
Mutual labels:  fastapi
fastapi-async-mongodb
Simple example with FastAPI + MongoDB
Stars: ✭ 49 (-55.45%)
Mutual labels:  fastapi
fastapi-project-template
DO NOT FORK, CLICK "Use this template" - The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.
Stars: ✭ 262 (+138.18%)
Mutual labels:  fastapi
Python-Studies
All studies about python
Stars: ✭ 56 (-49.09%)
Mutual labels:  fastapi
fastapi-project
FastAPI application without global variables(almost) =)
Stars: ✭ 26 (-76.36%)
Mutual labels:  fastapi
chitra
A multi-functional library for full-stack Deep Learning. Simplifies Model Building, API development, and Model Deployment.
Stars: ✭ 210 (+90.91%)
Mutual labels:  fastapi
fastapi-redis
Showcase of Redis integration with Python FastAPI framework as API backend for RDKit: Open-Source Cheminformatics Software
Stars: ✭ 46 (-58.18%)
Mutual labels:  fastapi
ecce
ML Prediction of Bible Topics and Passages (Python / React)
Stars: ✭ 36 (-67.27%)
Mutual labels:  fastapi
guane-intern-fastapi
FastAPI-PostgreSQL-Celery-RabbitMQ-Redis bakcend with Docker containerization
Stars: ✭ 54 (-50.91%)
Mutual labels:  fastapi

FastAPI Health 🚑️

Latest Commit
Package version

The goal of this package is to help you to implement the Health Check API pattern.

Installation

pip install fastapi-health

Quick Start

Create the health check endpoint dynamically using different conditions. Each condition is a callable, and you can even have dependencies inside of it:

from fastapi import FastAPI, Depends
from fastapi_health import health


def get_session():
    return True


def is_database_online(session: bool = Depends(get_session)):
    return session


app = FastAPI()
app.add_api_route("/health", health([is_database_online]))

Advanced Usage

The health() method receives the following parameters:

  • conditions: A list of callables that represents the conditions of your API, it can return either bool or a dict.
  • success_handler: An optional callable which receives the conditions results and returns a dictionary that will be the content response of a successful health call.
  • failure_handler: An optional callable analogous to success_handler for failure scenarios.
  • success_status: An integer that overwrites the default status (200) in case of success.
  • failure_status: An integer that overwrites the default status (503) in case of failure.

It's important to notice that you can have a peculiar behavior in case of hybrid return statements (bool and dict) on the conditions. For example:

from fastapi import FastAPI
from fastapi_health import health


def pass_condition():
    return {"database": "online"}


def sick_condition():
    return False


app = FastAPI()
app.add_api_route("/health", health([pass_condition, sick_condition]))

This will generate a response composed by the status being 503 (default failure_status), because sick_condition returns False, and the JSON body {"database": "online"}. It's not wrong, or a bug. It's meant to be like this.

License

This project is licensed under the terms of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].