| 202 | |
| 203 | |
| 204 | static Variant<check::Command, check::Http, check::Tcp> checkInfoToCheck( |
| 205 | const CheckInfo& checkInfo, |
| 206 | const string& launcherDir, |
| 207 | const Option<string>& scheme, |
| 208 | bool ipv6) |
| 209 | { |
| 210 | // Use the `CheckInfo` struct to create the right |
| 211 | // `check::{Command, Http, Tcp}` struct. |
| 212 | switch (checkInfo.type()) { |
| 213 | case CheckInfo::COMMAND: { |
| 214 | return check::Command(checkInfo.command().command()); |
| 215 | } |
| 216 | case CheckInfo::HTTP: { |
| 217 | const CheckInfo::Http& http = checkInfo.http(); |
| 218 | return check::Http( |
| 219 | http.port(), |
| 220 | http.has_path() ? http.path() : "", |
| 221 | scheme.getOrElse(check::DEFAULT_HTTP_SCHEME), |
| 222 | ipv6); |
| 223 | } |
| 224 | case CheckInfo::TCP: { |
| 225 | return check::Tcp(checkInfo.tcp().port(), launcherDir); |
| 226 | } |
| 227 | case CheckInfo::UNKNOWN: { |
| 228 | // TODO(josephw): Add validation at the agent or master level. |
| 229 | // Without validation, this is considered a mis-configuration of the |
| 230 | // task (user error). |
| 231 | LOG(FATAL) << "Received UNKNOWN check type"; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | UNREACHABLE(); |
| 236 | } |
| 237 | |
| 238 | |
| 239 | CheckerProcess::CheckerProcess( |