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

com.avito.android.runner.devices.internal.kubernetes.KubernetesReservationClientFactory.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

There is a newer version: 2024.32
Show newest version
package com.avito.android.runner.devices.internal.kubernetes

import com.avito.android.runner.devices.internal.EmulatorsLogsReporter
import com.avito.k8s.KubernetesApi
import com.avito.logger.LoggerFactory
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.sync.Mutex

@ExperimentalCoroutinesApi
internal class KubernetesReservationClientFactory(
    private val kubernetesApi: KubernetesApi,
    private val reservationDeploymentFactory: ReservationDeploymentFactory,
    private val emulatorsLogsReporter: EmulatorsLogsReporter,
    private val deviceProvider: RemoteDeviceProvider,
    private val listener: KubernetesReservationListener,
    private val loggerFactory: LoggerFactory,
    private val podsQueryIntervalMs: Long,
    private val dispatcher: CoroutineDispatcher
) {

    fun create(): KubernetesReservationClient {
        val lock = Mutex()
        return KubernetesReservationClient(
            claimer(lock),
            releaser(),
            listener,
            kubernetesApi,
            dispatcher,
            lock,
            loggerFactory
        )
    }

    private fun claimer(lock: Mutex): KubernetesReservationClaimer =
        KubernetesReservationClaimer(
            reservationDeploymentFactory,
            kubernetesApi,
            DeploymentPodsListener(lock, kubernetesApi, podsQueryIntervalMs, loggerFactory),
            deviceProvider,
            emulatorsLogsReporter,
            listener,
            lock,
            loggerFactory
        )

    private fun releaser(): KubernetesReservationReleaser =
        KubernetesReservationReleaser(
            kubernetesApi, deviceProvider, emulatorsLogsReporter, loggerFactory
        )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy