feat: expose get_satisfied_experiments and refactor code for resolution#755
feat: expose get_satisfied_experiments and refactor code for resolution#755
Conversation
Changed Files
|
| ) -> Result<serde_json::Map<String, Value>> { | ||
| self.eval_config(evaluation_context).await | ||
| prefix_filters: Option<Vec<String>>, | ||
| ) -> Result<(serde_json::Map<String, Value>, Vec<String>)> { |
There was a problem hiding this comment.
Should we make a type for this?
There was a problem hiding this comment.
Aliasing it for now
5fdfbca to
00fb43c
Compare
mahatoankitkumar
left a comment
There was a problem hiding this comment.
TODO for the next PR.
- Making a separate type instead of aliasing.
- And expose these functions in other providers too.
| .await | ||
| } | ||
|
|
||
| pub async fn get_running_experiments_from_provider(&self) -> Result<Experiments> { |
There was a problem hiding this comment.
Why call this get_running_experiments_from_provider while using the get_cached_experiments inside? 1-1 naming will be helpful here ?
- Add variants chosen to the Resolution Details so users can validate and debug
34c16c4 to
bf955aa
Compare
bf955aa to
128469a
Compare
| &self, | ||
| query_data: &serde_json::Map<String, Value>, | ||
| prefix_filter: Option<&[String]>, | ||
| prefix_filter: Option<Vec<String>>, |
There was a problem hiding this comment.
why not reference, if we dont need reference here then in line 233 of this file, we dont need the to_vec conversion anymore
| ); | ||
|
|
||
| let cac_config = CacConfig::new(superposition_options, config_options); | ||
| let cac_config = CacClient::new(superposition_options, config_options); |
There was a problem hiding this comment.
| let cac_config = CacClient::new(superposition_options, config_options); | |
| let cac_client = CacClient::new(superposition_options, config_options); |
| )); | ||
|
|
||
| let exp_config = ExperimentationConfig::new(superposition_options, exp_options); | ||
| let exp_config = ExperimentationClient::new(superposition_options, exp_options); |
There was a problem hiding this comment.
| let exp_config = ExperimentationClient::new(superposition_options, exp_options); | |
| let exp_client = ExperimentationClient::new(superposition_options, exp_options); |
| ) | ||
| } | ||
|
|
||
| pub async fn get_last_modified_time(&self) -> Result<DateTime<Utc>> { |
There was a problem hiding this comment.
this function name says last modified, but it is returning last updated
they seem totally different and confusing though
| flag_key: &str, | ||
| evaluation_context: &EvaluationContext, | ||
| converter: fn(&Value) -> EvaluationResult<T>, | ||
| ) -> EvaluationResult<ResolutionDetails<T>> { |
There was a problem hiding this comment.
astonishing! open-feature already had such types
| if targeting_key.is_some() { | ||
| if let Some(exp_config) = &self.exp_client { | ||
| let applicable_variant_ids = exp_config | ||
| .get_applicable_variants(&dimensions_info, &context, targeting_key) | ||
| .await?; | ||
|
|
||
| context.insert( | ||
| "variantIds".to_string(), | ||
| Value::Array(variant_ids.into_iter().map(Value::String).collect()), | ||
| ); | ||
|
|
||
| match &self.cac_config { | ||
| Some(cac_config) => cac_config.evaluate_config(&context, None).await, | ||
| None => Err(SuperpositionError::ConfigError( | ||
| "CAC config not initialized".into(), | ||
| )), | ||
| context.insert("variantIds".to_string(), json!(applicable_variant_ids)); | ||
| variant_ids = applicable_variant_ids; | ||
| } else { | ||
| log::warn!("Targeting key is set, but experiments have not been defined in the superposition provider builder options") | ||
| } | ||
| } | ||
| let Some(ref client) = self.cac_client else { |
There was a problem hiding this comment.
this section feels wrong, ideally shouldn't this have been separate and not part of eval_config, rather passed in to this
or maybe having this in here is still fine but not returned from every resolve operation
Problem
Internal juspay systems require more information from the provider to provide adequate debugging information
Solution
Future TODO
Have all s11n providers expose the same interface. This will be done in a future PR