Fix db health check
This commit is contained in:
parent
568a2c6831
commit
e6a7af840a
@ -8,6 +8,6 @@ interface HealthCheckService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class HealthCheckServiceImpl(private val dbHealthCheck: DbHealthCheck): HealthCheckService {
|
class HealthCheckServiceImpl(private val dbHealthCheck: DbHealthCheck) : HealthCheckService {
|
||||||
override fun isOk() = dbHealthCheck.isOk()
|
override fun isOk() = dbHealthCheck.isOk()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,7 @@ import be.simplenotes.persistance.utils.type
|
|||||||
import me.liuwj.ktorm.database.Database
|
import me.liuwj.ktorm.database.Database
|
||||||
import me.liuwj.ktorm.database.asIterable
|
import me.liuwj.ktorm.database.asIterable
|
||||||
import me.liuwj.ktorm.database.use
|
import me.liuwj.ktorm.database.use
|
||||||
import java.io.EOFException
|
import java.sql.SQLException
|
||||||
import java.sql.SQLTransientException
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
interface DbHealthCheck {
|
interface DbHealthCheck {
|
||||||
@ -26,9 +25,7 @@ internal class DbHealthCheckImpl(
|
|||||||
it.executeQuery().asIterable().map { it.getString(1) }
|
it.executeQuery().asIterable().map { it.getString(1) }
|
||||||
}
|
}
|
||||||
}.any { it in dataSourceConfig.jdbcUrl }
|
}.any { it in dataSourceConfig.jdbcUrl }
|
||||||
} catch (e: SQLTransientException) {
|
} catch (e: SQLException) {
|
||||||
false
|
|
||||||
} catch (e: EOFException) {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user