Apache Mesos
version.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 __VERSION_HPP__
18 #define __VERSION_HPP__
19 
20 #include <string>
21 
22 #include <process/future.hpp>
23 #include <process/http.hpp>
24 #include <process/process.hpp>
25 
26 #include "common/build.hpp"
27 
28 namespace mesos {
29 namespace internal {
30 
31 // Helper function to return Mesos version.
33 {
34  JSON::Object object;
35  object.values["version"] = MESOS_VERSION;
36 
37  if (build::GIT_SHA.isSome()) {
38  object.values["git_sha"] = build::GIT_SHA.get();
39  }
40 
41  if (build::GIT_BRANCH.isSome()) {
42  object.values["git_branch"] = build::GIT_BRANCH.get();
43  }
44 
45  if (build::GIT_TAG.isSome()) {
46  object.values["git_tag"] = build::GIT_TAG.get();
47  }
48 
49  object.values["build_date"] = build::DATE;
50  object.values["build_time"] = build::TIME;
51  object.values["build_user"] = build::USER;
52 
53  return object;
54 }
55 
56 
57 class VersionProcess : public process::Process<VersionProcess>
58 {
59 public:
61 
62 protected:
63  virtual void initialize();
64 
65 private:
68 };
69 
70 } // namespace internal {
71 } // namespace mesos {
72 
73 #endif // __VERSION_HPP__
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
const std::string USER
JSON::Object version()
Definition: version.hpp:32
std::map< std::string, Value > values
Definition: json.hpp:190
virtual void initialize()
Invoked when a process gets spawned.
Definition: http.hpp:518
Definition: json.hpp:154
const std::string DATE
Definition: spec.hpp:30
const T & get() const &
Definition: option.hpp:118
const Option< std::string > GIT_BRANCH
Definition: attributes.hpp:24
const Option< std::string > GIT_TAG
const Option< std::string > GIT_SHA
Definition: version.hpp:57
Definition: process.hpp:501
Definition: future.hpp:57