]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/baggage/RestrictionsConfig.h
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / jaeger-client-cpp / src / jaegertracing / baggage / RestrictionsConfig.h
1 /*
2 * Copyright (c) 2017 Uber Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H
18 #define JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H
19
20 #include "jaegertracing/Constants.h"
21 #include "jaegertracing/utils/YAML.h"
22 #include <chrono>
23 #include <string>
24
25 namespace jaegertracing {
26 namespace baggage {
27
28 class RestrictionsConfig {
29 public:
30 using Clock = std::chrono::steady_clock;
31
32 #ifdef JAEGERTRACING_WITH_YAML_CPP
33
34 static RestrictionsConfig parse(const YAML::Node& configYAML)
35 {
36 if (!configYAML.IsDefined() || !configYAML.IsMap()) {
37 return RestrictionsConfig();
38 }
39
40 const auto denyBaggageOnInitializationFailure =
41 utils::yaml::findOrDefault<bool>(
42 configYAML, "denyBaggageOnInitializationFailure", false);
43 const auto hostPort =
44 utils::yaml::findOrDefault<std::string>(configYAML, "hostPort", "");
45 const auto refreshInterval = std::chrono::seconds(
46 utils::yaml::findOrDefault<int>(configYAML, "refreshInterval", 0));
47 return RestrictionsConfig(
48 denyBaggageOnInitializationFailure, hostPort, refreshInterval);
49 }
50
51 #endif // JAEGERTRACING_WITH_YAML_CPP
52
53 explicit RestrictionsConfig(
54 bool denyBaggageOnInitializationFailure = false,
55 const std::string& hostPort = "",
56 const Clock::duration& refreshInterval = Clock::duration())
57 : _denyBaggageOnInitializationFailure(
58 denyBaggageOnInitializationFailure)
59 , _hostPort(hostPort)
60 , _refreshInterval(refreshInterval)
61 {
62 }
63
64 bool denyBaggageOnInitializationFailure() const
65 {
66 return _denyBaggageOnInitializationFailure;
67 }
68
69 const std::string& hostPort() const { return _hostPort; }
70
71 const Clock::duration& refreshInterval() const { return _refreshInterval; }
72
73 private:
74 bool _denyBaggageOnInitializationFailure;
75 std::string _hostPort;
76 Clock::duration _refreshInterval;
77 };
78
79 } // namespace baggage
80 } // namespace jaegertracing
81
82 #endif // JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H