Class: Datadog::OpenFeature::NativeEvaluator
- Inherits:
-
Object
- Object
- Datadog::OpenFeature::NativeEvaluator
- Defined in:
- lib/datadog/open_feature/native_evaluator.rb
Overview
This class is an interface of evaluation logic using native extension
Constant Summary collapse
- INVALID_FLAG_CONFIGURATION_ERROR_MESSAGE =
"flag configuration is invalid or unsupported"
Instance Attribute Summary collapse
-
#observe_full_evaluation_data ⇒ Object
readonly
Returns the value of attribute observe_full_evaluation_data.
Instance Method Summary collapse
-
#get_assignment(flag_key, default_value:, expected_type:, context:, experimentation_opt_out_mode: :disabled) ⇒ ResolutionDetails
Returns the assignment for a given flag key based on the feature flags configuration.
-
#initialize(configuration) ⇒ NativeEvaluator
constructor
NOTE: In a currect implementation configuration is expected to be a raw JSON string containing feature flags (straight from the remote config) in the format expected by
libdatadogwithout any modifications.
Constructor Details
#initialize(configuration) ⇒ NativeEvaluator
NOTE: In a currect implementation configuration is expected to be a raw
JSON string containing feature flags (straight from the remote config)
in the format expected by libdatadog without any modifications
16 17 18 19 |
# File 'lib/datadog/open_feature/native_evaluator.rb', line 16 def initialize(configuration) @configuration = Core::FeatureFlags::Configuration.new(configuration) @observe_full_evaluation_data = @configuration.observe_full_evaluation_data end |
Instance Attribute Details
#observe_full_evaluation_data ⇒ Object (readonly)
Returns the value of attribute observe_full_evaluation_data.
21 22 23 |
# File 'lib/datadog/open_feature/native_evaluator.rb', line 21 def observe_full_evaluation_data @observe_full_evaluation_data end |
Instance Method Details
#get_assignment(flag_key, default_value:, expected_type:, context:, experimentation_opt_out_mode: :disabled) ⇒ ResolutionDetails
Returns the assignment for a given flag key based on the feature flags configuration
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadog/open_feature/native_evaluator.rb', line 34 def get_assignment(flag_key, default_value:, expected_type:, context:, experimentation_opt_out_mode: :disabled) if experimentation_opt_out_mode != :disabled && context.key?("dd_experimentation_opt_out_at") = context["dd_experimentation_opt_out_at"] # The C binding drops nil and unsupported values, making them look absent, and truncates strings at NUL. # Reject them before conversion can permit experimentation; libdatadog checks the timestamp grammar. unless () return ResolutionDetails.build_error( value: default_value, error_code: Ext::INVALID_CONTEXT, error_message: "dd_experimentation_opt_out_at must be an RFC3339 timestamp string; " \ "supply a valid timestamp to opt out, or omit the attribute to permit experimentation", ) end end result = case experimentation_opt_out_mode when :immediate @configuration.(flag_key, expected_type, context, true) when :future_experiments_only @configuration.get_assignment_with_opt_out_mode(flag_key, expected_type, context, :future_experiments_only) else @configuration.get_assignment(flag_key, expected_type, context) end return invalid_flag_configuration_error(default_value) if invalid_flag_configuration?(result) build_resolution_details(result, default_value) end |