io.github.hylexus.jt.dashboard.server.service.Jt1078ServerSimpleMetricsUpdater Maven / Gradle / Ivy
package io.github.hylexus.jt.dashboard.server.service;
import io.github.hylexus.jt.dashboard.common.consts.JtDashboardConstants;
import io.github.hylexus.jt.dashboard.server.model.values.instance.JtInstance;
import io.github.hylexus.jt.dashboard.server.proxy.DashboardWebClient;
import io.github.hylexus.jt.dashboard.server.registry.Jt1078InstanceRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.ParameterizedTypeReference;
import reactor.core.publisher.Mono;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
/**
* 这个类是从 spring-boot-admin 中复制过来修改的。
*
* 这个类是从 spring-boot-admin 中复制过来修改的。
*
* 这个类是从 spring-boot-admin 中复制过来修改的。
*
* @see https://github.com/codecentric/spring-boot-admin
* @see de.codecentric.boot.admin.server.services.StatusUpdater
*/
@Slf4j
public class Jt1078ServerSimpleMetricsUpdater {
private final Jt1078InstanceRegistry instanceRegistry;
private final DashboardWebClient dashboardWebClient;
public Jt1078ServerSimpleMetricsUpdater(Jt1078InstanceRegistry instanceRegistry, DashboardWebClient.Builder builder) {
this.instanceRegistry = instanceRegistry;
this.dashboardWebClient = builder.build();
}
public Mono updateMetrics(String id) {
return this.instanceRegistry.getInstance(id).map(this::doUpdateMetrics).orElseGet(Mono::empty);
}
protected Mono doUpdateMetrics(JtInstance instance) {
log.debug("Update status for {}", instance);
return this.dashboardWebClient.mutateForInstance(instance)
.get()
.uri("/actuator/jt1078SimpleMetrics")
.retrieve().bodyToMono(new ParameterizedTypeReference