io.bitrise.gradle.cache.connection.CapabilitiesClient.kt Maven / Gradle / Ivy
package io.bitrise.gradle.cache.connection
import build.bazel.remote.execution.v2.CapabilitiesGrpcKt
import build.bazel.remote.execution.v2.GetCapabilitiesRequest
import build.bazel.remote.execution.v2.ServerCapabilities
import io.grpc.CallOptions
import io.grpc.ManagedChannel
import java.io.Closeable
import java.util.concurrent.TimeUnit
class CapabilitiesClient(
private val channel: ManagedChannel,
private val callOptions: CallOptions,
) : Closeable {
suspend fun getCapabilities(req: GetCapabilitiesRequest): ServerCapabilities {
val stub = CapabilitiesGrpcKt.CapabilitiesCoroutineStub(channel, callOptions)
return stub.getCapabilities(req)
}
override fun close() {
channel.shutdown().awaitTermination(2, TimeUnit.SECONDS)
}
}