-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: filter support in experimentation client #35
Conversation
pub async fn get_satisfied_experiments( | ||
&self, | ||
context: &Value, | ||
) -> Result<Experiments, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use App error here
&self, | ||
context: &Value, | ||
toss: i8, | ||
) -> Result<Vec<String>, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use App error here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use AppError here, this will be integrated in other codebases that may or may not understand the struct AppError
@@ -24,15 +30,16 @@ pub struct Client { | |||
// DO NOT let panics show up in library | |||
|
|||
impl Client { | |||
pub fn new(config: Config) -> Self { | |||
Client { | |||
pub fn new(config: Config) -> Result<Self, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use app error here also
mod utils; | ||
use std::{ | ||
collections::{HashMap, HashSet}, | ||
convert::identity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not getting used can you remove this
.collect::<Experiments>() | ||
.collect::<Experiments>(); | ||
|
||
if let Some(prefix) = context.get("prefix") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use different param for prefix, since its not related to the context instead with the filter,
we also might need to change this in cac_client
format!("Prefix is not a valid string.") | ||
}) | ||
.map_err_to_string()? | ||
.split(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we expect prefix as array of strings instead of comma separated string(since this is not query params of any api),
@@ -24,15 +30,16 @@ pub struct Client { | |||
// DO NOT let panics show up in library | |||
|
|||
impl Client { | |||
pub fn new(config: Config) -> Self { | |||
Client { | |||
pub fn new(config: Config) -> Result<Self, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need for this? Will we ever get an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to maintain consistency everywhere. Maybe in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not do it then? Lets add it when the error comes
&self, | ||
context: &Value, | ||
toss: i8, | ||
) -> Result<Vec<String>, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use AppError here, this will be integrated in other codebases that may or may not understand the struct AppError
ccd0976
to
71a5b45
Compare
71a5b45
to
77ad805
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some questions
9605a32
to
21348a3
Compare
@@ -187,9 +187,11 @@ pub extern "C" fn get_applicable_variant( | |||
let variants = local.block_on(&Runtime::new().unwrap(), unsafe { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this print statement ?
// println!("Fetching variantIds");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already removed, you seeing the code on the opposite(removed) side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not removed .
This was the comment that was removed :
// println!("variantIds: {:?}", variants);
match serde_json::to_string::<Vec<String>>(&variants) { | ||
Ok(result) => rstring_to_cstring(result).into_raw(), | ||
match variants { | ||
Ok(result) => match serde_json::to_string::<Vec<String>>(&result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variants_result
.map(|result| {
serde_json::to_string(&result)
.map(|json| rstring_to_cstring(json).into_raw())
.unwrap_or_else(|err| error_block(err.to_string()))
})
.unwrap_or_else(|err| error_block(err.to_string()))
let experiments = match serde_json::to_value(experiments) { | ||
Ok(value) => value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let experiments = serde_json::to_value(experiments)
.unwrap_or_else(|err| return error_block(err.to_string()));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this change at all the places ?
Ideally match statements should be used only for the cases where we have more than 2 conditions to match .
For these cases , we can directly leverage map .
21348a3
to
8003f3a
Compare
@@ -0,0 +1 @@ | |||
pub mod core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just put the code of core.rs into this file
8003f3a
to
2c307ec
Compare
Problem
Filter prefix from experiments.
Solution
Added Filter prefix support in experimentation client.