Module: Datadog::OpenFeature::SplitFeatures
- Defined in:
- lib/datadog/open_feature/split_features.rb
Overview
Copies the selected split's features into flag metadata, one entry per destination, and reads them back by destination prefix.
Constant Summary collapse
- DESTINATION_PREFIXES =
{ "HOOK" => Ext::METADATA_FEATURE_PREFIX, "EXPOSURE" => Ext::METADATA_EXPOSURE_FEATURE_PREFIX, "EVALUATION" => Ext::METADATA_EVALUATION_FEATURE_PREFIX, }.freeze
- MAX_WARNED_DESTINATIONS =
Bounds the memory spent remembering which unknown destinations were already warned about.
64- EMPTY =
{}.freeze
Class Method Summary collapse
- .read(metadata, prefix) ⇒ Object
-
.write(metadata, features) ⇒ Object
libdatadog already skips invalid features and keeps the first feature of a repeated key.
Class Method Details
.read(metadata, prefix) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/datadog/open_feature/split_features.rb', line 43 def read(, prefix) return EMPTY unless .is_a?(Hash) features = nil #: features_t? .each do |key, value| next unless key.is_a?(String) && key.start_with?(prefix) (features ||= {})[key[prefix.length, key.length]] = value end features ? features.freeze : EMPTY end |
.write(metadata, features) ⇒ Object
libdatadog already skips invalid features and keeps the first feature of a repeated key.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/datadog/open_feature/split_features.rb', line 28 def write(, features) features.each do |key, value, destinations| destinations.each do |destination| prefix = DESTINATION_PREFIXES[destination] if prefix ["#{prefix}#{key}"] = value else warn_unknown_destination(destination) end end end end |