From c39a20cf96814366f5de498f6a6f8b3feca7a3c4 Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Thu, 5 Nov 2020 14:44:59 +0100 Subject: [PATCH] Move health check to domain layer --- simplenotes-app/build.gradle.kts | 1 - .../app/controllers/HealthCheckController.kt | 6 +++--- .../domain/usecases/HealthCheckService.kt | 13 +++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 simplenotes-domain/src/main/kotlin/be/simplenotes/domain/usecases/HealthCheckService.kt diff --git a/simplenotes-app/build.gradle.kts b/simplenotes-app/build.gradle.kts index 9ad98fd..c7229d0 100644 --- a/simplenotes-app/build.gradle.kts +++ b/simplenotes-app/build.gradle.kts @@ -10,7 +10,6 @@ plugins { } dependencies { - implementation(project(":simplenotes-persistance")) implementation(project(":simplenotes-search")) implementation(project(":simplenotes-domain")) implementation(project(":simplenotes-types")) diff --git a/simplenotes-app/src/main/kotlin/be/simplenotes/app/controllers/HealthCheckController.kt b/simplenotes-app/src/main/kotlin/be/simplenotes/app/controllers/HealthCheckController.kt index c2c821a..33c827e 100644 --- a/simplenotes-app/src/main/kotlin/be/simplenotes/app/controllers/HealthCheckController.kt +++ b/simplenotes-app/src/main/kotlin/be/simplenotes/app/controllers/HealthCheckController.kt @@ -1,6 +1,6 @@ package be.simplenotes.app.controllers -import be.simplenotes.persistance.DbHealthCheck +import be.simplenotes.domain.usecases.HealthCheckService import org.http4k.core.Request import org.http4k.core.Response import org.http4k.core.Status.Companion.OK @@ -8,7 +8,7 @@ import org.http4k.core.Status.Companion.SERVICE_UNAVAILABLE import javax.inject.Singleton @Singleton -class HealthCheckController(private val dbHealthCheck: DbHealthCheck) { +class HealthCheckController(private val healthCheckService: HealthCheckService) { fun healthCheck(@Suppress("UNUSED_PARAMETER") request: Request) = - if (dbHealthCheck.isOk()) Response(OK) else Response(SERVICE_UNAVAILABLE) + if (healthCheckService.isOk()) Response(OK) else Response(SERVICE_UNAVAILABLE) } diff --git a/simplenotes-domain/src/main/kotlin/be/simplenotes/domain/usecases/HealthCheckService.kt b/simplenotes-domain/src/main/kotlin/be/simplenotes/domain/usecases/HealthCheckService.kt new file mode 100644 index 0000000..f23ac91 --- /dev/null +++ b/simplenotes-domain/src/main/kotlin/be/simplenotes/domain/usecases/HealthCheckService.kt @@ -0,0 +1,13 @@ +package be.simplenotes.domain.usecases + +import be.simplenotes.persistance.DbHealthCheck +import javax.inject.Singleton + +interface HealthCheckService { + fun isOk(): Boolean +} + +@Singleton +class HealthCheckServiceImpl(private val dbHealthCheck: DbHealthCheck): HealthCheckService { + override fun isOk() = dbHealthCheck.isOk() +}