Skip to content

Commit a80f236

Browse files
authored
refactor(server): rename typealiases for cached objects (#1943)
Part of #1938. We're going to get rid of `Result` in the type, so it makes sense to call the alias in a more generic way.
1 parent 4a34171 commit a80f236

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import kotlinx.coroutines.launch
2727

2828
private val logger = logger { }
2929

30-
typealias ArtifactResult = Result<Map<String, Artifact>?>
30+
typealias CachedVersionArtifact = Result<Map<String, Artifact>?>
3131

3232
private val prefetchScope = CoroutineScope(Dispatchers.IO)
3333

3434
fun Routing.artifactRoutes(
35-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
35+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
3636
prometheusRegistry: PrometheusMeterRegistry? = null,
3737
) {
3838
prometheusRegistry?.let {
@@ -50,15 +50,15 @@ fun Routing.artifactRoutes(
5050

5151
private fun Route.artifact(
5252
prometheusRegistry: PrometheusMeterRegistry?,
53-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
53+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
5454
refresh: Boolean = false,
5555
) {
5656
headArtifact(bindingsCache, prometheusRegistry, refresh)
5757
getArtifact(bindingsCache, prometheusRegistry, refresh)
5858
}
5959

6060
private fun Route.headArtifact(
61-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
61+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
6262
prometheusRegistry: PrometheusMeterRegistry?,
6363
refresh: Boolean,
6464
) {
@@ -78,7 +78,7 @@ private fun Route.headArtifact(
7878
}
7979

8080
private fun Route.getArtifact(
81-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
81+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
8282
prometheusRegistry: PrometheusMeterRegistry?,
8383
refresh: Boolean,
8484
) {
@@ -102,7 +102,7 @@ private fun Route.getArtifact(
102102

103103
internal fun prefetchBindingArtifacts(
104104
coords: Collection<ActionCoords>,
105-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
105+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
106106
) {
107107
prefetchScope.launch {
108108
bindingsCache.getAll(coords)
@@ -111,7 +111,7 @@ internal fun prefetchBindingArtifacts(
111111

112112
private suspend fun ApplicationCall.toBindingArtifacts(
113113
refresh: Boolean,
114-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
114+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
115115
): Map<String, Artifact>? {
116116
val actionCoords = parameters.extractActionCoords(extractVersion = true)
117117

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,24 @@ fun Application.appModule(
7777

7878
private fun buildBindingsCache(
7979
buildVersionArtifacts: (ActionCoords) -> Map<String, Artifact>?,
80-
): LoadingCache<ActionCoords, ArtifactResult> =
80+
): LoadingCache<ActionCoords, CachedVersionArtifact> =
8181
Caffeine
8282
.newBuilder()
8383
.refreshAfterWrite(1.hours)
8484
.recordStats()
85-
.asLoadingCache<ActionCoords, ArtifactResult> { runCatching { buildVersionArtifacts(it) } }
85+
.asLoadingCache<ActionCoords, CachedVersionArtifact> { runCatching { buildVersionArtifacts(it) } }
8686

8787
@Suppress("ktlint:standard:function-signature") // Conflict with detekt.
8888
private fun buildMetadataCache(
89-
bindingsCache: LoadingCache<ActionCoords, ArtifactResult>,
89+
bindingsCache: LoadingCache<ActionCoords, CachedVersionArtifact>,
9090
buildPackageArtifacts: suspend (ActionCoords, String, (Collection<ActionCoords>) -> Unit) -> Map<String, String>,
9191
getGithubAuthToken: () -> String,
92-
): LoadingCache<ActionCoords, MetadataResult> =
92+
): LoadingCache<ActionCoords, CachedMetadataArtifact> =
9393
Caffeine
9494
.newBuilder()
9595
.refreshAfterWrite(1.hours)
9696
.recordStats()
97-
.asLoadingCache<ActionCoords, MetadataResult> {
97+
.asLoadingCache<ActionCoords, CachedMetadataArtifact> {
9898
runCatching {
9999
buildPackageArtifacts(
100100
it,

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutes.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
1414

1515
private val logger = logger { }
1616

17-
typealias MetadataResult = Result<Map<String, String>>
17+
typealias CachedMetadataArtifact = Result<Map<String, String>>
1818

1919
fun Routing.metadataRoutes(
20-
metadataCache: LoadingCache<ActionCoords, MetadataResult>,
20+
metadataCache: LoadingCache<ActionCoords, CachedMetadataArtifact>,
2121
prometheusRegistry: PrometheusMeterRegistry? = null,
2222
) {
2323
prometheusRegistry?.let {
@@ -34,7 +34,7 @@ fun Routing.metadataRoutes(
3434
}
3535

3636
private fun Route.metadata(
37-
metadataCache: LoadingCache<ActionCoords, MetadataResult>,
37+
metadataCache: LoadingCache<ActionCoords, CachedMetadataArtifact>,
3838
refresh: Boolean = false,
3939
) {
4040
get {

0 commit comments

Comments
 (0)