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

pl.allegro.tech.servicemesh.envoycontrol.synchronization.AsyncRestTemplateControlPlaneClient.kt Maven / Gradle / Ivy

There is a newer version: 0.22.5
Show newest version
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