Skip to content

Commit

Permalink
Fix for service status response (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyktus authored Sep 27, 2018
1 parent 88abc47 commit fb8d852
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Jsend/ServiceStatusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,22 @@ public static function checkServices(
$servicesStatus = [];
foreach ($servicesClients as $serviceName => $serviceClient) {
$serviceName = $serviceClient->getName();

if (!empty($servicesStatus[$serviceName]) ||
in_array($serviceName, $whoAsks)) {
$servicesStatus[$serviceName] = StatusEnum::SUCCESS;
$servicesStatus[$serviceName] = !empty($serviceStatus[$serviceName]) ? $serviceStatus[$serviceName] : StatusEnum::SUCCESS;
continue;
}
$serviceStatusResult = ServiceStatusResponse::getServiceStatus($serviceClient, $whoAsks, $headers);
$data = $serviceStatusResult->getResponseBody();
if ($data['status'] !== StatusEnum::SUCCESS) {
if($data['status'] !== StatusEnum::SUCCESS) {
$status = StatusEnum::ERROR;
}
$servicesStatus[$serviceName] = $data['status'];
foreach ($data['data']['services'] as $key => $status) {
$servicesStatus[$key] = $status;
foreach ($data['data']['services'] as $key => $serviceStatus) {
$servicesStatus[$key] = $serviceStatus;
if($serviceStatus !== StatusEnum::SUCCESS) {
$status = StatusEnum::ERROR;
}
}
}
return $servicesStatus;
Expand Down

0 comments on commit fb8d852

Please sign in to comment.