pl.allegro.tech.servicemesh.envoycontrol.consul.synchronization.SimpleConsulInstanceFetcher.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-source-consul Show documentation
Show all versions of envoy-control-source-consul Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
The newest version!
package pl.allegro.tech.servicemesh.envoycontrol.consul.synchronization
import com.ecwid.consul.v1.ConsulClient
import com.ecwid.consul.v1.QueryParams
import com.ecwid.consul.v1.health.model.HealthService
import pl.allegro.tech.servicemesh.envoycontrol.synchronization.ControlPlaneInstanceFetcher
import java.net.URI
class SimpleConsulInstanceFetcher(
private val consulClient: ConsulClient,
private val envoyControlAppName: String
) : ControlPlaneInstanceFetcher {
override fun instances(cluster: String): List = toServiceUri(findInstances(cluster))
private fun toServiceUri(instances: MutableList) =
instances.map { instance -> createURI(instance.service.address, instance.service.port) }
private fun findInstances(nonLocalDc: String) =
consulClient.getHealthServices(envoyControlAppName, true, QueryParams(nonLocalDc)).value
private fun createURI(host: String, port: Int) = URI.create("http://$host:$port/")
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy