-
Notifications
You must be signed in to change notification settings - Fork 13
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
chore: Final pass addressing any outstanding comments #87
Changes from all commits
58a0809
7a4b6d7
70aaf0b
2b4cb38
5543941
15bf189
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,7 +641,7 @@ impl Client { | |
context: &Context, | ||
flag_key: &str, | ||
default_stage: Stage, | ||
) -> (Stage, MigrationOpTracker) { | ||
) -> (Stage, Arc<Mutex<MigrationOpTracker>>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mentioned this on the docs PR, but should we change this to return the You will also see in this PR I removed the internal mutex in the tracker as well. No need to pay for two lock penalties. |
||
let (detail, flag) = | ||
self.variation_internal(context, flag_key, default_stage, &self.events_default); | ||
|
||
|
@@ -655,7 +655,10 @@ impl Client { | |
default_stage, | ||
); | ||
|
||
(migration_detail.value.unwrap_or(default_stage), tracker) | ||
( | ||
migration_detail.value.unwrap_or(default_stage), | ||
Arc::new(Mutex::new(tracker)), | ||
) | ||
} | ||
|
||
/// Reports that a context has performed an event. | ||
|
@@ -1741,7 +1744,7 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.read( | ||
|_| async move { Ok(serde_json::Value::Null) }.boxed(), | ||
|_| async move { Ok(serde_json::Value::Null) }.boxed(), | ||
|
@@ -1761,17 +1764,17 @@ mod tests { | |
if let Operation::Read = operation { | ||
migrator | ||
.read( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
.await; | ||
} else { | ||
migrator | ||
.write( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
@@ -1855,7 +1858,7 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.track_latency(true) | ||
.read( | ||
|_| { | ||
|
@@ -1900,17 +1903,17 @@ mod tests { | |
if let Operation::Read = operation { | ||
migrator | ||
.read( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
.await; | ||
} else { | ||
migrator | ||
.write( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
@@ -1957,12 +1960,12 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.track_latency(true) | ||
.read( | ||
|_| async move { Err("fail".into()) }.boxed(), | ||
|_| async move { Err("fail".into()) }.boxed(), | ||
Some(|_, _| true), | ||
Some(|_: &String, _: &String| true), | ||
) | ||
.write( | ||
|_| async move { Err("fail".into()) }.boxed(), | ||
|
@@ -1977,8 +1980,8 @@ mod tests { | |
|
||
migrator | ||
.read( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
@@ -2026,7 +2029,7 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.track_latency(true) | ||
.read( | ||
|_| async move { Ok(serde_json::Value::Null) }.boxed(), | ||
|
@@ -2046,8 +2049,8 @@ mod tests { | |
|
||
migrator | ||
.write( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
@@ -2117,7 +2120,7 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.track_latency(true) | ||
.read( | ||
|_| async move { Ok(serde_json::Value::Null) }.boxed(), | ||
|
@@ -2155,8 +2158,8 @@ mod tests { | |
|
||
migrator | ||
.write( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
@@ -2202,7 +2205,7 @@ mod tests { | |
) | ||
.expect("patch should apply"); | ||
|
||
let migrator = MigratorBuilder::new(client.clone()) | ||
let mut migrator = MigratorBuilder::new(client.clone()) | ||
.track_latency(true) | ||
.read( | ||
|_| { | ||
|
@@ -2246,8 +2249,8 @@ mod tests { | |
|
||
migrator | ||
.read( | ||
&context, | ||
"stage-flag".into(), | ||
context, | ||
Stage::Off, | ||
serde_json::Value::Null, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ impl BaseEvent { | |
} | ||
} | ||
|
||
/// MigrationOpEventData is generated through the migration op tracker provided through the SDK. | ||
/// A MigrationOpEvent is generated through the migration op tracker provided through the SDK. | ||
#[derive(Clone, Debug)] | ||
pub struct MigrationOpEvent { | ||
pub(crate) base: BaseEvent, | ||
|
@@ -131,21 +131,17 @@ impl Serialize for MigrationOpEvent { | |
key: self.key.clone(), | ||
value: self.evaluation.value, | ||
default: self.default_stage, | ||
// QUESTION: In the ruby implementation, this can be nil. Why not here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ruby one is needlessly checking for nil. 🤦🏼 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In client-side SDKs the reason is optional, so maybe it is for bootstrapping from ruby? But it would always be populated. |
||
reason: self.evaluation.reason.clone(), | ||
variation_index: self.evaluation.variation_index, | ||
version: self.version, | ||
}; | ||
state.serialize_field("evaluation", &evaluation)?; | ||
|
||
// TODO: Add sampling here if it is set and not 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done above. Forgot to remove this then. |
||
|
||
let mut measurements = vec![]; | ||
if !self.invoked.is_empty() { | ||
measurements.push(MigrationOpMeasurement::Invoked(&self.invoked)); | ||
} | ||
|
||
// TODO: There is something here to do with consistency check ratio | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No there isn't. |
||
if let Some(consistency_check) = self.consistency_check { | ||
measurements.push(MigrationOpMeasurement::ConsistencyCheck( | ||
consistency_check, | ||
|
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.
We don't need to consume the context, and the parameter order change makes this consistent with the variation methods.