forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: splitting classes into two files (envoyproxy#9576)
Risk Level: n/a (just moving code) Testing: n/a Docs Changes: n/a Release Notes: n/a Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
- Loading branch information
1 parent
bbf96ab
commit e7a7e8b
Showing
8 changed files
with
71 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/config/core/v3alpha/base.pb.h" | ||
#include "envoy/runtime/runtime.h" | ||
#include "envoy/type/v3alpha/percent.pb.h" | ||
|
||
#include "common/protobuf/utility.h" | ||
|
||
namespace Envoy { | ||
namespace Runtime { | ||
|
||
// Helper class for runtime-derived boolean feature flags. | ||
class FeatureFlag { | ||
public: | ||
FeatureFlag(const envoy::config::core::v3alpha::RuntimeFeatureFlag& feature_flag_proto, | ||
Runtime::Loader& runtime) | ||
: runtime_key_(feature_flag_proto.runtime_key()), | ||
default_value_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(feature_flag_proto, default_value, true)), | ||
runtime_(runtime) {} | ||
|
||
bool enabled() const { return runtime_.snapshot().getBoolean(runtime_key_, default_value_); } | ||
|
||
private: | ||
const std::string runtime_key_; | ||
const bool default_value_; | ||
Runtime::Loader& runtime_; | ||
}; | ||
|
||
// Helper class for runtime-derived fractional percent flags. | ||
class FractionalPercent { | ||
public: | ||
FractionalPercent( | ||
const envoy::config::core::v3alpha::RuntimeFractionalPercent& fractional_percent_proto, | ||
Runtime::Loader& runtime) | ||
: runtime_key_(fractional_percent_proto.runtime_key()), | ||
default_value_(fractional_percent_proto.default_value()), runtime_(runtime) {} | ||
|
||
bool enabled() const { return runtime_.snapshot().featureEnabled(runtime_key_, default_value_); } | ||
|
||
private: | ||
const std::string runtime_key_; | ||
const envoy::type::v3alpha::FractionalPercent default_value_; | ||
Runtime::Loader& runtime_; | ||
}; | ||
|
||
} // namespace Runtime | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters