Apache Mesos
checks_types.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __CHECKS_TYPES_HPP__
18 #define __CHECKS_TYPES_HPP__
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 #include <mesos/mesos.hpp>
25 
26 #include <stout/option.hpp>
27 
28 namespace mesos {
29 namespace internal {
30 namespace checks {
31 namespace check {
32 
33 // Use '127.0.0.1' and '::1' instead of 'localhost', because the
34 // host file in some container images may not contain 'localhost'.
35 constexpr char DEFAULT_IPV4_DOMAIN[] = "127.0.0.1";
36 constexpr char DEFAULT_IPV6_DOMAIN[] = "::1";
37 
38 constexpr char DEFAULT_HTTP_SCHEME[] = "http";
39 
40 // The nested command check requires the entire command info struct
41 // so this struct is just a wrapper around `CommandInfo`.
42 struct Command {
43  explicit Command(const CommandInfo& _info) : info(_info) {}
44 
45  CommandInfo info;
46 };
47 
48 struct Http {
49  explicit Http(
50  uint32_t _port,
51  const std::string& _path,
52  const std::string& _scheme = DEFAULT_HTTP_SCHEME,
53  bool ipv6 = false)
54  : port(_port),
55  path(_path),
56  scheme(_scheme),
57  domain(ipv6 ? "[" + std::string(DEFAULT_IPV6_DOMAIN) + "]"
58  : DEFAULT_IPV4_DOMAIN) {}
59 
60  uint32_t port;
61  std::string path;
62  std::string scheme;
63  std::string domain;
64 };
65 
66 struct Tcp {
67  explicit Tcp(
68  uint32_t _port,
69  const std::string& _launcherDir,
70  bool ipv6 = false)
71  : port(_port),
72  launcherDir(_launcherDir),
73  domain(ipv6 ? DEFAULT_IPV6_DOMAIN : DEFAULT_IPV4_DOMAIN) {}
74 
75  uint32_t port;
76  std::string launcherDir;
77  std::string domain;
78 };
79 
80 } // namespace check {
81 } // namespace checks {
82 } // namespace internal {
83 } // namespace mesos {
84 
85 #endif // __CHECKS_TYPES_HPP__
Definition: path.hpp:26
Tcp(uint32_t _port, const std::string &_launcherDir, bool ipv6=false)
Definition: checks_types.hpp:67
constexpr char DEFAULT_HTTP_SCHEME[]
Definition: checks_types.hpp:38
Try< Nothing > check()
uint32_t port
Definition: checks_types.hpp:75
Definition: type_utils.hpp:550
std::string domain
Definition: checks_types.hpp:77
Definition: checks_types.hpp:66
constexpr char DEFAULT_IPV4_DOMAIN[]
Definition: checks_types.hpp:35
Definition: spec.hpp:26
CommandInfo info
Definition: checks_types.hpp:45
std::string domain
Definition: checks_types.hpp:63
constexpr char DEFAULT_IPV6_DOMAIN[]
Definition: checks_types.hpp:36
std::string launcherDir
Definition: checks_types.hpp:76
uint32_t port
Definition: checks_types.hpp:60
Definition: attributes.hpp:24
std::string scheme
Definition: checks_types.hpp:62
Definition: checks_types.hpp:48
Http(uint32_t _port, const std::string &_path, const std::string &_scheme=DEFAULT_HTTP_SCHEME, bool ipv6=false)
Definition: checks_types.hpp:49
Definition: checks_types.hpp:42
Command(const CommandInfo &_info)
Definition: checks_types.hpp:43
std::string path
Definition: checks_types.hpp:61