| 137 | |
| 138 | |
| 139 | static Try<Nothing> interpretCheckStatusInfo(const CheckStatusInfo& result) |
| 140 | { |
| 141 | switch (result.type()) { |
| 142 | case CheckInfo::COMMAND: { |
| 143 | const int exitCode = result.command().exit_code(); |
| 144 | if (exitCode != 0) { |
| 145 | return Error("Command " + WSTRINGIFY(exitCode)); |
| 146 | } |
| 147 | |
| 148 | break; |
| 149 | } |
| 150 | case CheckInfo::HTTP: { |
| 151 | const int statusCode = result.http().status_code(); |
| 152 | if (statusCode < process::http::Status::OK || |
| 153 | statusCode >= process::http::Status::BAD_REQUEST) { |
| 154 | return Error( |
| 155 | "Unexpected HTTP response code: " + |
| 156 | process::http::Status::string(statusCode)); |
| 157 | } |
| 158 | |
| 159 | break; |
| 160 | } |
| 161 | case CheckInfo::TCP: { |
| 162 | if (!result.tcp().succeeded()) { |
| 163 | return Error("TCP connection failed"); |
| 164 | } |
| 165 | |
| 166 | break; |
| 167 | } |
| 168 | case CheckInfo::UNKNOWN: { |
| 169 | break; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return Nothing(); |
| 174 | } |
| 175 | |
| 176 | |
| 177 | Try<Owned<HealthChecker>> HealthChecker::create( |
no test coverage detected