Move health check to domain layer
This commit is contained in:
parent
bf56314473
commit
c39a20cf96
@ -10,7 +10,6 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":simplenotes-persistance"))
|
|
||||||
implementation(project(":simplenotes-search"))
|
implementation(project(":simplenotes-search"))
|
||||||
implementation(project(":simplenotes-domain"))
|
implementation(project(":simplenotes-domain"))
|
||||||
implementation(project(":simplenotes-types"))
|
implementation(project(":simplenotes-types"))
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package be.simplenotes.app.controllers
|
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.Request
|
||||||
import org.http4k.core.Response
|
import org.http4k.core.Response
|
||||||
import org.http4k.core.Status.Companion.OK
|
import org.http4k.core.Status.Companion.OK
|
||||||
@ -8,7 +8,7 @@ import org.http4k.core.Status.Companion.SERVICE_UNAVAILABLE
|
|||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class HealthCheckController(private val dbHealthCheck: DbHealthCheck) {
|
class HealthCheckController(private val healthCheckService: HealthCheckService) {
|
||||||
fun healthCheck(@Suppress("UNUSED_PARAMETER") request: Request) =
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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()
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user