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

pl.allegro.tech.servicemesh.envoycontrol.services.ServiceInstances.kt Maven / Gradle / Ivy

package pl.allegro.tech.servicemesh.envoycontrol.services

data class ServiceInstance(
    val id: String,
    val tags: Set,
    val address: String?,
    val port: Int?,
    val regular: Boolean = true,
    val canary: Boolean = false,
    val weight: Int = 1
)

data class ServiceInstances(
    val serviceName: String,
    val instances: Set
) {
    fun withoutEmptyAddressInstances(): ServiceInstances =
        if (instances.any { it.address.isNullOrEmpty() }) {
            copy(instances = instances.asSequence()
                .filter { !it.address.isNullOrEmpty() }
                .toSet())
        } else this

    fun withoutInvalidPortInstances(): ServiceInstances =
        if (instances.any { it.port == null }) {
            copy(instances = instances.asSequence()
                .filter { it.port != null }
                .toSet())
        } else this
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy