2 * Copyright (c) 2017 Uber Technologies, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H
18 #define JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H
20 #include "jaegertracing/Constants.h"
21 #include "jaegertracing/utils/YAML.h"
25 namespace jaegertracing
{
28 class RestrictionsConfig
{
30 using Clock
= std::chrono::steady_clock
;
32 #ifdef JAEGERTRACING_WITH_YAML_CPP
34 static RestrictionsConfig
parse(const YAML::Node
& configYAML
)
36 if (!configYAML
.IsDefined() || !configYAML
.IsMap()) {
37 return RestrictionsConfig();
40 const auto denyBaggageOnInitializationFailure
=
41 utils::yaml::findOrDefault
<bool>(
42 configYAML
, "denyBaggageOnInitializationFailure", false);
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
);
51 #endif // JAEGERTRACING_WITH_YAML_CPP
53 explicit RestrictionsConfig(
54 bool denyBaggageOnInitializationFailure
= false,
55 const std::string
& hostPort
= "",
56 const Clock::duration
& refreshInterval
= Clock::duration())
57 : _denyBaggageOnInitializationFailure(
58 denyBaggageOnInitializationFailure
)
60 , _refreshInterval(refreshInterval
)
64 bool denyBaggageOnInitializationFailure() const
66 return _denyBaggageOnInitializationFailure
;
69 const std::string
& hostPort() const { return _hostPort
; }
71 const Clock::duration
& refreshInterval() const { return _refreshInterval
; }
74 bool _denyBaggageOnInitializationFailure
;
75 std::string _hostPort
;
76 Clock::duration _refreshInterval
;
79 } // namespace baggage
80 } // namespace jaegertracing
82 #endif // JAEGERTRACING_BAGGAGE_RESTRICTIONSCONFIG_H