Giter Club home page Giter Club logo

kealth's Introduction

Kealth

Kealth is a health check library for external dependencies in Kotlin

CircleCI Known Vulnerabilities codecov Maven Central Codacy Badge ktlint HitCount License

Installation

Maven

<repositories>
    <repository>
        <id>central</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>

<dependency>
    <groupId>io.github.marioalvial</groupId>
    <artifactId>kealth</artifactId>
    <version>${kealth-version}</version>
</dependency>

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation "io.github.marioalvial:kealth:$kealth_version"
}    

Getting Started

  1. Create your component:
class HealthComponentA : HealthComponent() {

    override val name = "component A"

    override fun doHealthCheck(): HealthStatus {
        val result = doHealthCheckCallToComponentAService()
        return if(result) HealthStatus.HEALTHY else HealthStatus.UNHEALTHY
    }

    override fun handleFailure(throwable: Throwable) {
        sendAlert()
    }
}
  1. Instantiate HealthAggregator:
val aggregator = HealthAggregator(listOf(HealthComponentA()))
  1. Execute aggregate():
val componentMap: Map<String, HealthInfo> = aggregator.aggregate() 

Example of componentMap serialized to json:

{
	"component-A": {
		"status": "HEALTHY",
		"duration": 1500
	},
	"component-B": {
		"status": "UNHEALTHY",
		"duration": 400
	}
}

Handle Failure

handleFailure() will be trigger only if doHealthCheck() call throws exception.

How it works

When aggregator.aggregate() is called it will execute health() of each component in parallel and create a map with the component's name as key and health info as value.

If the doHealthCheck() throws exception the component will trigger the handleFailure() method asynchronous with the exception that was thrown.

Continuous Integration and Test Coverage

Test Coverage configured on CodeCov. Checkout the test coverage here.

Continuous Integration is configured on CircleCI. Checkout the continuous integration here

Testing

./gradlew test

Built With

kealth's People

Contributors

marioalvial avatar leonisandes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.