Skip to content

Commit

Permalink
Merge pull request #197 from urviljoshi/heathcheck-consolidator
Browse files Browse the repository at this point in the history
503 respstatus added in case of  status as down
  • Loading branch information
ckm007 authored Aug 19, 2022
2 parents aa6f064 + 8c49369 commit 8b6cc5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions consolidator/consolidator_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import ballerina/jballerina.java;

http:Service healthCheckService = service object {

resource function get .() returns healthcheck:HealthCheckResp {
resource function get .() returns http:Ok|http:ServiceUnavailable {
//diskspace
string diskSpaceStatus = "DOWN";
handle handleStr = java:fromString(config:CURRENT_WORKING_DIR);
Expand Down Expand Up @@ -59,11 +59,15 @@ http:Service healthCheckService = service object {
string resultStatus = "DOWN";
if(diskSpaceStatus == "UP" && kafkaStatus == "UP"){
resultStatus = "UP";
healthcheck:HealthCheckResp healthCheckResp = {status: resultStatus, details: {details}};
http:Ok res = {body: healthCheckResp};
return res;
}

//main object
healthcheck:HealthCheckResp healthCheckResp = {status: resultStatus, details: {details}};
return healthCheckResp;
http:ServiceUnavailable res = {body: healthCheckResp};
return res;
}
};

Expand Down
9 changes: 6 additions & 3 deletions hub/hub_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import ballerina/jballerina.java;

http:Service healthCheckService = service object {

resource function get .() returns healthcheck:HealthCheckResp {
resource function get .() returns http:Ok|http:ServiceUnavailable{
//diskspace
string diskSpaceStatus = "DOWN";
handle handleStr = java:fromString(config:CURRENT_WORKING_DIR);
Expand Down Expand Up @@ -60,10 +60,13 @@ http:Service healthCheckService = service object {
string resultStatus = "DOWN";
if(diskSpaceStatus == "UP" && consolidatorStatus == "UP"){
resultStatus = "UP";
healthcheck:HealthCheckResp healthCheckResp = {status: resultStatus, details: {details}};
http:Ok res = {body: healthCheckResp};
return res;
}
//main object
healthcheck:HealthCheckResp healthCheckResp = {status: resultStatus, details: {details}};
return healthCheckResp;
http:ServiceUnavailable res = {body: healthCheckResp};
return res;
}
};

Expand Down

0 comments on commit 8b6cc5f

Please sign in to comment.