1
#pragma once
2

            
3
#include <cstdint>
4

            
5
#include "envoy/runtime/runtime.h"
6

            
7
#include "source/common/singleton/const_singleton.h"
8

            
9
#include "absl/container/flat_hash_map.h"
10
#include "absl/flags/commandlineflag.h"
11
#include "absl/flags/flag.h"
12
#include "absl/strings/string_view.h"
13

            
14
namespace Envoy {
15
namespace Runtime {
16

            
17
bool hasRuntimePrefix(absl::string_view feature);
18
bool isRuntimeFeature(absl::string_view feature);
19

            
20
// Returns true if the feature is one of the legacy runtime features that uses the
21
// `envoy.reloadable_features` prefix but is not implemented like all other runtime
22
// feature flags.
23
bool isLegacyRuntimeFeature(absl::string_view feature);
24

            
25
bool runtimeFeatureEnabled(absl::string_view feature);
26
uint64_t getInteger(absl::string_view feature, uint64_t default_value);
27

            
28
void markRuntimeInitialized();
29
bool isRuntimeInitialized();
30

            
31
void maybeSetRuntimeGuard(absl::string_view name, bool value);
32

            
33
void maybeSetDeprecatedInts(absl::string_view name, uint32_t value);
34
constexpr absl::string_view upstream_http_filters_with_tcp_proxy =
35
    "envoy.restart_features.upstream_http_filters_with_tcp_proxy";
36

            
37
// This is a singleton class to map Envoy style flag names to absl flags
38
class RuntimeFeatures {
39
public:
40
  RuntimeFeatures();
41

            
42
  // Get the command line flag corresponding to the Envoy style feature name, or
43
  // nullptr if it is not a registered flag.
44
  absl::CommandLineFlag* getFlag(absl::string_view feature) const;
45

            
46
private:
47
  absl::flat_hash_map<std::string, absl::CommandLineFlag*> all_features_;
48
};
49

            
50
using RuntimeFeaturesDefaults = ConstSingleton<RuntimeFeatures>;
51

            
52
} // namespace Runtime
53
} // namespace Envoy