chore: Minimal surface API for HealthCheckServiceCE (#32347)
This commit is contained in:
parent
b220151d3e
commit
57b62797ff
|
|
@ -1,13 +1,7 @@
|
||||||
package com.appsmith.server.services.ce;
|
package com.appsmith.server.services.ce;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.health.Health;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
public interface HealthCheckServiceCE {
|
public interface HealthCheckServiceCE {
|
||||||
|
|
||||||
Mono<String> getHealth();
|
Mono<String> getHealth();
|
||||||
|
|
||||||
Mono<Health> getRedisHealth();
|
|
||||||
|
|
||||||
Mono<Health> getMongoHealth();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.actuate.data.mongo.MongoReactiveHealthIndicator;
|
import org.springframework.boot.actuate.data.mongo.MongoReactiveHealthIndicator;
|
||||||
import org.springframework.boot.actuate.data.redis.RedisReactiveHealthIndicator;
|
import org.springframework.boot.actuate.data.redis.RedisReactiveHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.Health;
|
import org.springframework.boot.actuate.health.Health;
|
||||||
import org.springframework.boot.actuate.health.Status;
|
|
||||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||||
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
@ -30,11 +29,10 @@ public class HealthCheckServiceCEImpl implements HealthCheckServiceCE {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<String> getHealth() {
|
public Mono<String> getHealth() {
|
||||||
return Mono.zip(getRedisHealth(), getMongoHealth()).map(tuple -> "All systems are Up");
|
return Mono.when(getRedisHealth(), getMongoHealth()).thenReturn("All systems are up");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Mono<Health> getRedisHealth() {
|
||||||
public Mono<Health> getRedisHealth() {
|
|
||||||
Function<TimeoutException, Throwable> healthTimeout = error -> {
|
Function<TimeoutException, Throwable> healthTimeout = error -> {
|
||||||
log.warn("Redis health check timed out: {}", error.getMessage());
|
log.warn("Redis health check timed out: {}", error.getMessage());
|
||||||
return new AppsmithException(AppsmithError.HEALTHCHECK_TIMEOUT, "Redis");
|
return new AppsmithException(AppsmithError.HEALTHCHECK_TIMEOUT, "Redis");
|
||||||
|
|
@ -47,8 +45,7 @@ public class HealthCheckServiceCEImpl implements HealthCheckServiceCE {
|
||||||
.onErrorMap(TimeoutException.class, healthTimeout);
|
.onErrorMap(TimeoutException.class, healthTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Mono<Health> getMongoHealth() {
|
||||||
public Mono<Health> getMongoHealth() {
|
|
||||||
Function<TimeoutException, Throwable> healthTimeout = error -> {
|
Function<TimeoutException, Throwable> healthTimeout = error -> {
|
||||||
log.warn("MongoDB health check timed out: {}", error.getMessage());
|
log.warn("MongoDB health check timed out: {}", error.getMessage());
|
||||||
return new AppsmithException(AppsmithError.HEALTHCHECK_TIMEOUT, "Mongo");
|
return new AppsmithException(AppsmithError.HEALTHCHECK_TIMEOUT, "Mongo");
|
||||||
|
|
@ -60,11 +57,4 @@ public class HealthCheckServiceCEImpl implements HealthCheckServiceCE {
|
||||||
.timeout(Duration.ofSeconds(1))
|
.timeout(Duration.ofSeconds(1))
|
||||||
.onErrorMap(TimeoutException.class, healthTimeout);
|
.onErrorMap(TimeoutException.class, healthTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUp(Health health) {
|
|
||||||
if (Status.UP.equals(health.getStatus())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user