Skip to content

Commit

Permalink
Revert "allow running without db for testing"
Browse files Browse the repository at this point in the history
This reverts commit 8caea56.
  • Loading branch information
anderssonw committed Jul 9, 2024
1 parent c7da069 commit d2437f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
18 changes: 8 additions & 10 deletions src/main/kotlin/no/kartverket/matrikkel/bygning/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,15 @@ fun Application.internalModule() {

DatabaseSingleton.init()
val dbConnection = DatabaseSingleton.getConnection()
val healthRepository = HealthRepository(dbConnection)
val healthService = HealthService(healthRepository)

if (dbConnection != null) {
val healthRepository = HealthRepository(dbConnection)
val healthService = HealthService(healthRepository)

routing {
get("/metrics") {
call.respondText(appMicrometerRegistry.scrape())
}

probeRouting(healthService)
routing {
get("/metrics") {
call.respondText(appMicrometerRegistry.scrape())
}

probeRouting(healthService)
}

}
17 changes: 5 additions & 12 deletions src/main/kotlin/no/kartverket/matrikkel/bygning/db/DBSingleton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,11 @@ object DatabaseSingleton {
}
}

fun getConnection(): Connection? {
try {
if (connection != null) {
return connection as Connection
}

throw RuntimeException("Kunne ikke koble til database")

} catch (e: Exception) {
LOGGER.error(e.stackTraceToString())

return null
fun getConnection(): Connection {
if (connection != null) {
return connection as Connection
}

throw RuntimeException("Kunne ikke koble til database")
}
}

0 comments on commit d2437f9

Please sign in to comment.