Skip to content

Health Check

Add health check endpoints to your Kairo application with just a few lines of code.

val healthChecks = mapOf(
"sql" to HealthCheck { SqlFeature.healthCheck(koin) },
"custom" to HealthCheck {
// ...
},
)

Install kairo-health-check-feature.

build.gradle.kts
dependencies {
implementation("software.airborne.kairo:kairo-health-check-feature")
}
val features = listOf(
HealthCheckFeature(),
)

This creates 2 endpoints.

  • GET /health/liveness returns 200 OK if the server is running.
  • GET /health/readiness returns 200 OK if all health checks pass.

You’re probably going to want to customize the readiness checks. Implement the HealthCheck functional interface. Throw an exception to fail the check.

val healthChecks = mapOf(
"sql" to HealthCheck { SqlFeature.healthCheck(koin) },
"custom" to HealthCheck {
// ...
},
)
val features = listOf(
HealthCheckFeature(healthChecks),
)

Depending on which other Framework Features you’re using, you might get other health checks for free.

  • SQL Feature
    HealthCheck { SqlFeature.healthCheck(koin) }

The Health Check Feature has a few more options you can configure.

  • includeDefaultHealthCheck is true by default. This check ensures that the Server is running. If the server is still starting, or has begun stopping, it will fail.
  • timeout is 2 seconds by default. You can adjust this if needed.