File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed
jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver
maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -24,12 +24,17 @@ import io.ktor.server.routing.route
24
24
import io.micrometer.core.instrument.Tag
25
25
import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics
26
26
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
27
+ import kotlinx.coroutines.CoroutineScope
28
+ import kotlinx.coroutines.Dispatchers
29
+ import kotlinx.coroutines.launch
27
30
import kotlin.time.Duration.Companion.hours
28
31
29
32
private val logger = logger { }
30
33
31
34
typealias ArtifactResult = Result <Map <String , Artifact >>
32
35
36
+ private val prefetchScope = CoroutineScope (Dispatchers .IO )
37
+
33
38
private val bindingsCache =
34
39
Caffeine
35
40
.newBuilder()
@@ -98,6 +103,12 @@ private fun Route.getArtifact(
98
103
}
99
104
}
100
105
106
+ internal fun prefetchBindingArtifacts (coords : Collection <ActionCoords >) {
107
+ prefetchScope.launch {
108
+ bindingsCache.getAll(coords)
109
+ }
110
+ }
111
+
101
112
private suspend fun ApplicationCall.toBindingArtifacts (refresh : Boolean ): Map <String , Artifact >? {
102
113
val actionCoords = parameters.extractActionCoords(extractVersion = true )
103
114
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ private val metadataCache =
28
28
.recordStats()
29
29
.asLoadingCache<ActionCoords , MetadataResult > {
30
30
runCatching {
31
- it.buildPackageArtifacts(githubAuthToken = getGithubAuthToken())
31
+ it.buildPackageArtifacts(githubAuthToken = getGithubAuthToken(), ::prefetchBindingArtifacts )
32
32
}
33
33
}
34
34
Original file line number Diff line number Diff line change @@ -18,13 +18,15 @@ internal suspend fun ActionCoords.buildMavenMetadataFile(
18
18
name: String ,
19
19
githubAuthToken: String? ,
20
20
) -> Either <String , List <Version >> = ::fetchAvailableVersions,
21
+ prefetchBindingArtifacts : (Collection <ActionCoords >) -> Unit = {},
21
22
): String? {
22
23
val availableVersions =
23
24
fetchAvailableVersions(owner, name, githubAuthToken)
24
25
.getOrElse {
25
26
logger.error { it }
26
27
emptyList()
27
28
}.filter { it.isMajorVersion() || (significantVersion < FULL ) }
29
+ prefetchBindingArtifacts(availableVersions.map { copy(version = " $it " ) })
28
30
val newest = availableVersions.maxOrNull() ? : return null
29
31
val lastUpdated =
30
32
DateTimeFormatter
Original file line number Diff line number Diff line change @@ -2,8 +2,15 @@ package io.github.typesafegithub.workflows.mavenbinding
2
2
3
3
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords
4
4
5
- suspend fun ActionCoords.buildPackageArtifacts (githubAuthToken : String ): Map <String , String > {
6
- val mavenMetadata = buildMavenMetadataFile(githubAuthToken = githubAuthToken) ? : return emptyMap()
5
+ suspend fun ActionCoords.buildPackageArtifacts (
6
+ githubAuthToken : String ,
7
+ prefetchBindingArtifacts : (Collection <ActionCoords >) -> Unit ,
8
+ ): Map <String , String > {
9
+ val mavenMetadata =
10
+ buildMavenMetadataFile(
11
+ githubAuthToken = githubAuthToken,
12
+ prefetchBindingArtifacts = prefetchBindingArtifacts,
13
+ ) ? : return emptyMap()
7
14
return mapOf (
8
15
" maven-metadata.xml" to mavenMetadata,
9
16
" maven-metadata.xml.md5" to mavenMetadata.md5Checksum(),
You can’t perform that action at this time.
0 commit comments