Skip to content

Commit

Permalink
replace if-else chain with cleaner switch block
Browse files Browse the repository at this point in the history
Signed-off-by: Drew S. Ortega <[email protected]>
  • Loading branch information
drewsortega committed Aug 17, 2020
1 parent 2c300ae commit 4f192d4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions source/common/upstream/health_discovery_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,17 @@ envoy::service::health::v3::HealthCheckRequestOrEndpointHealthResponse HdsDelega
if (host->health() == Host::Health::Healthy) {
endpoint->set_health_status(envoy::config::core::v3::HEALTHY);
} else {
if (host->getActiveHealthFailureType() == Host::ActiveHealthFailureType::TIMEOUT) {
switch (host->getActiveHealthFailureType()) {
case Host::ActiveHealthFailureType::TIMEOUT:
endpoint->set_health_status(envoy::config::core::v3::TIMEOUT);
} else if (host->getActiveHealthFailureType() ==
Host::ActiveHealthFailureType::UNHEALTHY) {
break;
case Host::ActiveHealthFailureType::UNHEALTHY:
case Host::ActiveHealthFailureType::UNKNOWN:
endpoint->set_health_status(envoy::config::core::v3::UNHEALTHY);
} else if (host->getActiveHealthFailureType() ==
Host::ActiveHealthFailureType::UNKNOWN) {
endpoint->set_health_status(envoy::config::core::v3::UNHEALTHY);
} else {
break;
default:
NOT_REACHED_GCOVR_EXCL_LINE;
break;
}
}

Expand Down

0 comments on commit 4f192d4

Please sign in to comment.