Skip to content
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

Merged
merged 6 commits into from
Jul 3, 2024

Conversation

keelerm84
Copy link
Member

No description provided.

@keelerm84 keelerm84 requested a review from a team June 13, 2024 17:45
@keelerm84 keelerm84 force-pushed the mk/sc-243772/expand-contract-tests branch from 8c09081 to a728012 Compare June 18, 2024 04:04
Copy link
Member Author

@keelerm84 keelerm84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will require updates to the docs PR (I also noted that there), but I think these are good changes. LMK what you think!

@@ -641,7 +641,7 @@ impl Client {
context: &Context,
flag_key: &str,
default_stage: Stage,
) -> (Stage, MigrationOpTracker) {
) -> (Stage, Arc<Mutex<MigrationOpTracker>>) {
Copy link
Member Author

Choose a reason for hiding this comment

The 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 Arc<Mutex<>>? Both the kit and the blocks would require doing this at some point anyway so it's kind of a convenience in a sense.

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.

match params.operation {
launchdarkly_server_sdk::Operation::Read => {
let result = migrator
.read(
&params.context,
Copy link
Member Author

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.

@@ -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?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ruby one is needlessly checking for nil. 🤦🏼

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there isn't.

@@ -43,79 +43,63 @@ pub struct MigrationWriteResult<T> {
// provided results are equal, this method will return true and false otherwise.
type MigrationComparisonFn<T> = fn(&T, &T) -> bool;

struct MigrationConfig<T, FO, FN>
struct MigrationConfig<P, T, FO, FN>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally this was requiring the read or write payload parameter to be the same type as the return of those methods. That isn't a requirement of the spec so we should reflect that appropriately. So lots of type changes here.

{
/// Create a new migrator builder instance with the provided client.
pub fn new(client: Arc<Client>) -> Self {
MigratorBuilder {
client,
read_execution_order: ExecutionOrder::Parallel,
read_execution_order: ExecutionOrder::Concurrent,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also changed this to reflect the actual execution method.

@@ -24,8 +23,6 @@ pub struct MigrationOpTracker {
context: Context,
detail: Detail<Stage>,
default_stage: Stage,

mutex: Mutex<()>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the interior mutex as mentioned previously.

Base automatically changed from mk/sc-243772/expand-contract-tests to feat/migrations July 3, 2024 14:08
@keelerm84 keelerm84 merged commit a1e8dfa into feat/migrations Jul 3, 2024
3 checks passed
@keelerm84 keelerm84 deleted the mk/sc-247332/polish branch July 3, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants