Skip to content

Commit

Permalink
Merge pull request #44 from chinmoy12c/hotfix/fix_campaign_health_end…
Browse files Browse the repository at this point in the history
…point

Fixed campaign healthpoint according to v2 changes.
  • Loading branch information
pankajjangid05 authored May 3, 2023
2 parents 1ce2546 + 86787b4 commit 9f496b9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/com/uci/utils/UtilHealthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
public class UtilHealthService {
@Value("${campaign.url}")
String campaignUrl;

@Value("${campaign.admin.token}")
String campaignAdminToken;

@Autowired
private KafkaConfig kafkaConfig;
Expand Down Expand Up @@ -68,18 +71,22 @@ public Mono<JsonNode> getCampaignUrlHealthNode() {
try {
WebClient webClient = WebClient.create(campaignUrl);
return webClient.get()
.uri(builder -> builder.path("admin/v1/health").build())
.uri(builder -> builder.path("admin/health/ping").build())
.header("admin-token", campaignAdminToken)
.retrieve()
.bodyToMono(JsonNode.class)
.onErrorResume(e -> {
failed.put("message", e.getMessage());
return Mono.just(mapper.createObjectNode().set("result", failed));
return Mono.just(failed);
})
.map(jsonNode -> {
ObjectNode result = mapper.createObjectNode();
result.put("status", jsonNode.get("result").get("status").textValue());
if (jsonNode.get("result").get("status").textValue().equals(Status.DOWN.getCode())) {
result.set("message", jsonNode.get("result").get("message"));
if (jsonNode.get("status").textValue().equalsIgnoreCase("ok")) {
result.put("status", jsonNode.get("details").get("UCI-API").get("status").textValue().equalsIgnoreCase(Status.UP.getCode()) ? "UP" : "DOWN");
}
else {
result.put("status", "DOWN");
result.set("message", jsonNode.get("message"));
}
return result;
});
Expand Down

0 comments on commit 9f496b9

Please sign in to comment.