All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gabrielfeo.develocity.api.extension.Mapping.kt Maven / Gradle / Ivy

The newest version!
package com.gabrielfeo.develocity.api.extension

import com.gabrielfeo.develocity.api.*
import com.gabrielfeo.develocity.api.model.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*

/**
 * Joins builds with their [GradleAttributes], which comes from a different endpoint
 * ([BuildsApi.getGradleAttributes]).
 *
 * Don't expect client-side filtering to be efficient. Does as many concurrent calls
 * as it can, requesting attributes in an eager coroutine, in [scope].
 */
internal fun Flow.withGradleAttributes(
    scope: CoroutineScope,
    api: BuildsApi,
): Flow> =
    map { build ->
        build to scope.async {
            api.getGradleAttributes(build.id)
        }
    }.buffer(Int.MAX_VALUE).map { (build, attrs) ->
        build to attrs.await()
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy