sksamuel / cohort Goto Github PK
View Code? Open in Web Editor NEWKtor/Vertx spring-actuator style library - healthchecks, logging, database
License: Apache License 2.0
Ktor/Vertx spring-actuator style library - healthchecks, logging, database
License: Apache License 2.0
actual:
There is version 2.0.2
of cohort-core
:
But the latest version of cohort-ktor
and cohort-ktor2
is 1.7.3
:
When I clone the project and run ./gradlew publishMavenJavaPublicationToMavenLocal
artifacts are NOT created.
I also found the commit that removes cohort-ktor
and cohort-ktor2
: 9fe382f1efe8034a14ef3caef7f22ae3bf2db637
expected:
Should we update the documentation about how to use cohort 2.x?
See BufferPoolMXBean
Hi,
As the title says, I get not found error, could that be an oversight?
Could not find com.sksamuel.cohort:cohort-core:2.5.0.
Searched in the following locations:
Receiving this error:
> Task :restserver:compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':restserver:compileKotlin'.
> Could not resolve all files for configuration ':restserver:compileClasspath'.
> Could not find com.sksamuel.cohort:cohort-ktor2:2.0.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/sksamuel/cohort/cohort-ktor2/2.0.2/cohort-ktor2-2.0.2.pom
- https://jitpack.io/com/sksamuel/cohort/cohort-ktor2/2.0.2/cohort-ktor2-2.0.2.pom
Required by:
project :restserver
Looked in Maven:
The HikariConnectionsHealthCheck
seems to permanently hold connections and prevent the data source from cleaning up.
Below, is a demonstration.
import arrow.continuations.SuspendApp
import arrow.core.Either
import arrow.fx.coroutines.closeable
import arrow.fx.coroutines.continuations.ResourceScope
import arrow.fx.coroutines.resourceScope
import com.sksamuel.cohort.HealthCheckRegistry
import com.sksamuel.cohort.hikari.HikariConnectionsHealthCheck
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import kotlinx.coroutines.Dispatchers
import kotlin.system.exitProcess
import kotlin.time.DurationUnit
import kotlin.time.toDuration
data class Services(val hikariDataSource: HikariDataSource)
fun createHikariDS(): HikariDataSource =
HikariConfig().apply {
jdbcUrl = "jdbc:h2:mem:kjs;DB_CLOSE_DELAY=-1"
username = "sa"
password = ""
maximumPoolSize = 1
}.let { HikariDataSource(it) }
// Makes all the components into resources and bundles them up.
suspend fun ResourceScope.createServices(dataSource: HikariDataSource): Services =
Services(
hikariDataSource = closeable { dataSource }
)
fun createHealthChecks(ds: HikariDataSource): HealthCheckRegistry =
HealthCheckRegistry(Dispatchers.Default) {
register(HikariConnectionsHealthCheck(ds, 1), 5.toDuration(DurationUnit.SECONDS))
}
fun main() {
val dataSource = createHikariDS()
// This causes the server to not exit because it holds a connection on the dataSource.
val registry = createHealthChecks(dataSource)
SuspendApp {
resourceScope {
Either.catch {
createServices(dataSource)
require(false) { "So, does it close?" }
}.onLeft {
println("Fatal exception in server: ${it.message}")
}
}
}
println("DONE")
// HealthChecks holds a DB connection, which hangs the process.
// exitProcess(0)
}
See GarbageCollectorMXBean
Hey, we update our dependencies via a bot that constantly tries to update this dependency since you released a new version. Unfortunately, it is not on Maven Central. Since it has been two weeks, I wanted to ask when you plan to upload it there. https://mvnrepository.com/artifact/com.sksamuel.cohort/cohort-core
Need to reverse the logic for the errorOnYellow flag in the ElasticClusterHealthCheck
When enabling the memory pool information endpoint with
install(Cohort) {
memory = true
}
and subsequently calling the /cohort/memory endpoint, the following exception is thrown on OpenJDK 17:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type `sun.management.MemoryPoolImpl`: Failed to construct BeanSerializer for [simple type, class sun.management.MemoryPoolImpl]: (java.lang.IllegalArgumentException) Failed to call `setAccess()` on Method 'getName' (of class `sun.management.MemoryPoolImpl`) due to `java.lang.reflect.InaccessibleObjectException`, problem: Unable to make public java.lang.String sun.management.MemoryPoolImpl.getName() accessible: module java.management does not "opens sun.management" to unnamed module @557a1e2d (through reference chain: com.sksamuel.cohort.memory.MemoryInfo["memoryPools"]->java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:72)
at com.fasterxml.jackson.databind.SerializerProvider.reportBadTypeDefinition(SerializerProvider.java:1302)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanOrAddOnSerializer(BeanSerializerFactory.java:475)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanOrAddOnSerializer(BeanSerializerFactory.java:295)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:240)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1525)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1473)
at com.fasterxml.jackson.databind.SerializerProvider.findContentValueSerializer(SerializerProvider.java:811)
at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddSecondarySerializer(PropertySerializerMap.java:90)
at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase._findAndAddDynamic(AsArraySerializerBase.java:314)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:115)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4799)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:4040)
at com.sksamuel.cohort.endpoints.JsonKt.toJson(json.kt:38)
at com.sksamuel.cohort.endpoints.EndpointsKt$cohort$3.invokeSuspend(endpoints.kt:42)
at com.sksamuel.cohort.endpoints.EndpointsKt$cohort$3.invoke(endpoints.kt)
at com.sksamuel.cohort.endpoints.EndpointsKt$cohort$3.invoke(endpoints.kt)
at io.ktor.server.routing.Route$buildPipeline$1$1.invokeSuspend(Route.kt:116)
at io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt)
at io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:109)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
at io.ktor.server.routing.Routing.executeResult(Routing.kt:190)
at io.ktor.server.routing.Routing.interceptor(Routing.kt:64)
at io.ktor.server.routing.Routing$Plugin$install$1.invokeSuspend(Routing.kt:140)
at io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt)
at io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invokeSuspend(BaseApplicationEngine.kt:124)
at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt)
at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
at io.ktor.server.application.hooks.CallFailed$install$1$1.invokeSuspend(CommonHooks.kt:45)
at io.ktor.server.application.hooks.CallFailed$install$1$1.invoke(CommonHooks.kt)
at io.ktor.server.application.hooks.CallFailed$install$1$1.invoke(CommonHooks.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:261)
at io.ktor.server.application.hooks.CallFailed$install$1.invokeSuspend(CommonHooks.kt:44)
at io.ktor.server.application.hooks.CallFailed$install$1.invoke(CommonHooks.kt)
at io.ktor.server.application.hooks.CallFailed$install$1.invoke(CommonHooks.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:109)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invokeSuspend(DefaultEnginePipeline.kt:123)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:109)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2.invokeSuspend(CIOApplicationEngine.kt:239)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.