-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
639be96
commit 7fc2fbe
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/uk/gov/hmcts/reform/authorisation/healthcheck/InternalHealth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package uk.gov.hmcts.reform.authorisation.healthcheck; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.springframework.boot.actuate.health.Status; | ||
|
||
import java.util.Map; | ||
|
||
public class InternalHealth { | ||
private final Status status; | ||
private final Map<String, Object> details; | ||
|
||
@JsonCreator | ||
public InternalHealth( | ||
@JsonProperty("status") Status status, | ||
@JsonProperty("details") Map<String, Object> details | ||
) { | ||
this.status = status; | ||
this.details = details; | ||
} | ||
|
||
public Status getStatus() { | ||
return status; | ||
} | ||
|
||
public Map<String, Object> getDetails() { | ||
return details; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/uk/gov/hmcts/reform/authorisation/healthcheck/ServiceAuthHealthIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package uk.gov.hmcts.reform.authorisation.healthcheck; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.actuate.health.HealthIndicator; | ||
import org.springframework.stereotype.Component; | ||
import uk.gov.hmcts.reform.authorisation.ServiceAuthorisationApi; | ||
|
||
@Component | ||
public class ServiceAuthHealthIndicator implements HealthIndicator { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceAuthHealthIndicator.class); | ||
|
||
private final ServiceAuthorisationApi serviceAuthorisationApi; | ||
|
||
@Autowired | ||
public ServiceAuthHealthIndicator(final ServiceAuthorisationApi serviceAuthorisationApi) { | ||
this.serviceAuthorisationApi = serviceAuthorisationApi; | ||
} | ||
|
||
@Override | ||
public Health health() { | ||
try { | ||
InternalHealth internalHealth = this.serviceAuthorisationApi.health(); | ||
return new Health.Builder(internalHealth.getStatus()).build(); | ||
} catch (Exception ex) { | ||
LOGGER.error("Error on service auth healthcheck", ex); | ||
return Health.down(ex).build(); | ||
} | ||
} | ||
} |