pl.allegro.tech.servicemesh.envoycontrol.synchronization.AsyncRestTemplateControlPlaneClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-runner Show documentation
Show all versions of envoy-control-runner Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
package pl.allegro.tech.servicemesh.envoycontrol.synchronization
import io.micrometer.core.instrument.MeterRegistry
import org.springframework.web.client.AsyncRestTemplate
import pl.allegro.tech.servicemesh.envoycontrol.services.ServicesState
import reactor.core.publisher.Mono
import java.net.URI
import java.util.concurrent.TimeUnit
class AsyncRestTemplateControlPlaneClient(
private val asyncRestTemplate: AsyncRestTemplate,
private val meterRegistry: MeterRegistry
) : AsyncControlPlaneClient {
override fun getState(uri: URI): Mono {
return Mono.fromCompletionStage {
asyncRestTemplate.getForEntity("$uri/state", ServicesState::class.java)
.completable()
.thenApply { it.body }
}
.elapsed()
.map { t ->
meterRegistry.timer("sync-dc.get-state.time").record(t.t1, TimeUnit.MILLISECONDS)
t.t2
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy