All Projects → zensum → ktor-health-check

zensum / ktor-health-check

Licence: MIT License
Simple, opinionated health checks Kubernetes-style health checks for ktor

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to ktor-health-check

kmm
Rick & Morty Kotlin Multiplatform Mobile: Ktor, Sqldelight, Koin, Flow, MVI, SwiftUI, Compose
Stars: ✭ 52 (+100%)
Mutual labels:  ktor
jellyfin-sdk-kotlin
Kotlin SDK for Jellyfin, supporting Android and JVM Targets
Stars: ✭ 43 (+65.38%)
Mutual labels:  ktor
xodus-entity-browser
Web UI entity browser for xodus database
Stars: ✭ 56 (+115.38%)
Mutual labels:  ktor
kotlin-ktor-realworld-example-app
Real world backend API built in Kotlin with Ktor + Kodein + Exposed
Stars: ✭ 117 (+350%)
Mutual labels:  ktor
ToDometer Multiplatform
WIP Kotlin Multiplatform project: A meter to-do list built with Android Jetpack, Compose UI Multiplatform, Wear Compose, SQLDelight, Koin Multiplatform, SwiftUI, Ktor Server / Client, Exposed...
Stars: ✭ 145 (+457.69%)
Mutual labels:  ktor
intro-kotlin-mutliplatform
Kotlin Multiplatform project (MPP), JVM and JS
Stars: ✭ 21 (-19.23%)
Mutual labels:  ktor
ComposeTodo
Sample project to play with Jetpack Compose on Android, Desktop and Web
Stars: ✭ 64 (+146.15%)
Mutual labels:  ktor
kompendium
Ktor OpenAPI Spec Generator
Stars: ✭ 46 (+76.92%)
Mutual labels:  ktor
multi-projects-architecture-with-Ktor
A Ktor real world example built on multi-projects architecture
Stars: ✭ 29 (+11.54%)
Mutual labels:  ktor
tmdb-api
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.
Stars: ✭ 31 (+19.23%)
Mutual labels:  ktor
ktor demo
ktor demo
Stars: ✭ 22 (-15.38%)
Mutual labels:  ktor
local-data-api
Data API for local, you can write unittest for AWS Aurora Serverless's Data API
Stars: ✭ 99 (+280.77%)
Mutual labels:  ktor
Duga
Stack Exchange Chat bot
Stars: ✭ 20 (-23.08%)
Mutual labels:  ktor
RocketXDelight-Playground
Native Android application built with Kotlin and Jetpack Compose. This project also illustrates the usage of advanced libraries such as Ktor, SqlDelight, Hilt, etc with the recommended practices and Unit Tests.
Stars: ✭ 37 (+42.31%)
Mutual labels:  ktor
RiRi
An optical character recognition mobile application built using Kotlin Multiplatform Mobile and Azure Cognitive Services
Stars: ✭ 31 (+19.23%)
Mutual labels:  ktor
JavaneseBackend
Javanese.online website back-end
Stars: ✭ 31 (+19.23%)
Mutual labels:  ktor
Lastik
Kotlin Multiplatform + Jetpack Compose pet project, based on www.last.fm/api (in development)
Stars: ✭ 37 (+42.31%)
Mutual labels:  ktor
ktor-auth-jwt-sample
A simple but slightly more elaborate example of how to include JWT in the Ktor application flow.
Stars: ✭ 100 (+284.62%)
Mutual labels:  ktor
ktor-hexagonal-multimodule
Template project to build ktor-based multi-module web service with Kotlin using Hexagonal architecture
Stars: ✭ 30 (+15.38%)
Mutual labels:  ktor
meu kumbu
💵Meu Kumbu 💰 (Means My Money) is a template app that people can use to build their owns Wallet 🤑 or a mobile 🏦 banking app.
Stars: ✭ 55 (+111.54%)
Mutual labels:  ktor

ktor-health-check

license

Simple, opinionated ktor health and readiness checks made for Kubernetes.

import ktor_health_check.Health

fun main(args: Array<String>) {
    embeddedServer(Netty, 80) {
        // Install the middleware...
        install(Health)
    }.start(wait = true)
}

... and boom, the your application now exposes a /healthz and /readyz endpoint for use with for example Kubernetes. For a simple application this is all you configuration you will ever need. In a more complicated application we might want to our readycheck to start failing if the database goes down.

fun main(args: Array<String>) {
    embeddedServer(Netty, 80) {
        install(Health) {
            readyCheck("database") { myDatabase.ping() }
        }
    }.start(wait = true)
}

And now getting /readyz returns:

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 17

{"database":true}

Lets add another check

install(Health) {
            readyCheck("database") { myDatabase.ping() }
            readyCheck("redis") { redis.ping() }
}

Now lets say someone tripped on the cord for our Redis server.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Content-Length: 31

{"database":true,"redis":false}

The database check is still returning true, but redis has turned false. If any single check is down, as is the case here, the result of the entire request becomes 500, indicating that the service isn't operational.

For some use-cases you may want to expose checks on URLs other than /healthz and /readyz. In that case we need to use customCheck

customCheck("/smoketest", "database") { database.test() }

And the smoketest should now be avaliable on /smoketest

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].