🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

fastapi-healthchecks

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastapi-healthchecks

FastAPI Healthchecks

pipPyPI
Version
1.1.0
Maintainers
3

FastAPI health checks

Configurable health checks endpoints for FastAPI applications.

Quickstart

app = FastAPI()
app.include_router(
    HealthcheckRouter(
        Probe(
            name="readiness",
            checks=[
                PostgreSqlCheck(host="db.example.com", username=..., password=...),
                RedisCheck(host="redis.example.com", username=..., password=...),
            ],
        ),
        Probe(
            name="liveness",
            checks=[
                ...,
            ],
        ),
    ),
    prefix="/health",
)

The probes from this example will be available as GET /health/readiness and GET /health/liveness.

Bundled checks

  • PostgreSqlCheck – checks PostgreSQL server availability
  • RedisCheck – checks Redis server availability
  • RabbitMqCheck – checks RabbitMQ server availability
  • SettingsCheck – validates settings models based on pydantic BaseModel
  • HttpCheck – checks availability of specified URL
  • CephCheck – checks Ceph server availability

Custom checks

You can create your own checks by providing custom fastapi_healthchecks.checks.Check implementations. Like this:

class MaintenanceCheck(Check):
    async def __call__(self) -> CheckResult:
        if is_maintenance():
            return CheckResult(name="Maintenance", passed=False, details="Closed for maintenance")
        else:
            return CheckResult(name="Maintenance", passed=True)

Keywords

fastapi

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts