Skip to content

Commit

Permalink
JAMES-3929 Refactor HealthCheck to have a constant for timeout that a…
Browse files Browse the repository at this point in the history
…ll health checks can use if necessary

Timeout needed on OpenSearchHealthCheck after upgrade, as it seems the requests was waiting forever on it.
  • Loading branch information
Arsnael committed Jul 19, 2023
1 parent ee5bef7 commit 36d5d46
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public Mono<Result> check() {

try {
return client.health(request)
.timeout(HEALTH_CHECK_TIMEOUT)
.map(this::toHealthCheckResult)
.onErrorResume(e -> Mono.just(Result.unhealthy(COMPONENT_NAME, "Error while contacting cluster", e)));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
****************************************************************/
package org.apache.james.core.healthcheck;

import java.time.Duration;

import org.reactivestreams.Publisher;

public interface HealthCheck {
Duration HEALTH_CHECK_TIMEOUT = Duration.ofSeconds(5);

ComponentName componentName();

Publisher<Result> check();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.james.rspamd.healthcheck;

import java.time.Duration;

import javax.inject.Inject;

import org.apache.james.core.healthcheck.ComponentName;
Expand All @@ -33,7 +31,6 @@

public class RspamdHealthCheck implements HealthCheck {
private static final ComponentName COMPONENT_NAME = new ComponentName("Rspamd");
private static final Duration HEALTH_CHECK_TIMEOUT = Duration.ofSeconds(5);

private final RspamdHttpClient rspamdHttpClient;

Expand Down

0 comments on commit 36d5d46

Please sign in to comment.