File tree Expand file tree Collapse file tree 3 files changed +7
-29
lines changed
jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver Expand file tree Collapse file tree 3 files changed +7
-29
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,13 @@ import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
2525import kotlinx.coroutines.CoroutineScope
2626import kotlinx.coroutines.Dispatchers
2727import kotlinx.coroutines.launch
28+ import java.util.Optional
29+ import kotlin.jvm.optionals.getOrNull
2830
2931private val logger = logger { }
3032
33+ typealias CachedVersionArtifact = Optional <VersionArtifacts >
34+
3135private val prefetchScope = CoroutineScope (Dispatchers .IO )
3236
3337fun Routing.artifactRoutes (
@@ -118,7 +122,7 @@ private suspend fun ApplicationCall.toBindingArtifacts(
118122 if (refresh) {
119123 bindingsCache.invalidate(actionCoords)
120124 }
121- return bindingsCache.get(actionCoords).toNullableVersionArtifacts ()
125+ return bindingsCache.get(actionCoords).getOrNull ()
122126}
123127
124128private fun PrometheusMeterRegistry.incrementArtifactCounter (
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import io.micrometer.core.instrument.Tag
2626import io.micrometer.prometheusmetrics.PrometheusConfig
2727import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
2828import java.time.Duration
29+ import java.util.Optional
2930import kotlin.time.Duration.Companion.hours
3031
3132private val logger =
@@ -109,7 +110,7 @@ private fun buildBindingsCache(
109110 .newBuilder()
110111 .refreshAfterWrite(1 .hours)
111112 .recordStats()
112- .asLoadingCache { buildVersionArtifacts(it, httpClient).toCachedVersionArtifact( ) }
113+ .asLoadingCache { Optional .ofNullable( buildVersionArtifacts(it, httpClient)) }
113114
114115@Suppress(" ktlint:standard:function-signature" ) // Conflict with detekt.
115116private fun buildMetadataCache (
You can’t perform that action at this time.
0 commit comments