Skip to content

Commit

Permalink
Støtt flere helsesjekker via Builder
Browse files Browse the repository at this point in the history
Co-authored-by: Geir André Lund <geir.andre.lund@nav.no>
  • Loading branch information
2 people authored and davidsteinsland committed Nov 22, 2024
1 parent 7c8474f commit 92c3e84
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/kotlin/no/nav/helse/rapids_rivers/RapidApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class RapidApplication internal constructor(
private var naisEndpoints = NaisEndpoints.Default
private var statusPagesConfig: StatusPagesConfig.() -> Unit = { defaultStatusPagesConfig() }
private var callIdHeader: String = "callId"
private val isAliveChecks = mutableSetOf<() -> Boolean>(rapid::isRunning)
private val isReadyChecks = mutableSetOf<() -> Boolean>(rapid::isReady)

fun withHttpPort(httpPort: Int) = apply {
this.httpPort = httpPort
Expand All @@ -217,10 +219,18 @@ class RapidApplication internal constructor(
naisEndpoints = naisEndpoints.copy(isreadyEndpoint = isAliveEndpoint)
}

fun withIsAliveCheck(check: () -> Boolean) = apply {
isAliveChecks.add(check)
}

fun withIsReadyEndpoint(isReadyEndpoint: String) = apply {
naisEndpoints = naisEndpoints.copy(isreadyEndpoint = isReadyEndpoint)
}

fun withIsReadyCheck(check: () -> Boolean) = apply {
isReadyChecks.add(check)
}

fun withMetricsEndpoint(metricsEndpoint: String) = apply {
naisEndpoints = naisEndpoints.copy(metricsEndpoint = metricsEndpoint)
}
Expand All @@ -246,8 +256,8 @@ class RapidApplication internal constructor(
naisEndpoints = naisEndpoints,
callIdHeaderName = callIdHeader,
port = httpPort,
aliveCheck = rapid::isRunning,
readyCheck = rapid::isReady,
aliveCheck = { isAliveChecks.all { it() } },
readyCheck = { isReadyChecks.all { it() } },
preStopHook = stopHook::handlePreStopRequest,
cioConfiguration = cioConfiguration,
statusPagesConfig = statusPagesConfig,
Expand Down

0 comments on commit 92c3e84

Please sign in to comment.