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

fix: allow multiple client tokens at startup #188

Merged
merged 1 commit into from
May 18, 2023

Conversation

sighphyre
Copy link
Member

Fixes an issue where providing multiple tokens on startup with identical environments and projects would result in no tokens being registered.

This was caused by overeager subsumption of the tokens - identical tokens would subsume each other, and therefore the result of two identical tokens would be no tokens. I've patched this by creating a new list of only tokens that do not have a match for identical project/environment before we do the subsumption.

@@ -145,12 +145,8 @@ impl FeatureRefresher {
}

///
/// Registers a token for refresh, returns true if token did not exist and as such needs hydration before we can guarantee that we have data for it
Copy link
Member Author

@sighphyre sighphyre May 18, 2023

Choose a reason for hiding this comment

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

Patches to this function are just for sanity. The doc string got outdated here and we never updated it. This function could also never fail - there was no path to raise an error but the function signature suggested that it could, so now the return signature reflects that . You'll see a few places in this PR where

let _ = feature_refresher has been swapped for feature_refresher, which is married to the change to this function

.collect()
}

fn filter_unique_tokens(tokens: &[TokenRefresh]) -> Vec<TokenRefresh> {
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 TokenRefresh type already has a Hash impl, so we gotta go the long way around to make a unique list here

@sighphyre sighphyre requested a review from gastonfournier May 18, 2023 12:23
Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

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

I think this looks fine, especially the test case gives me confidence that this is the right thing to do 👍

@sighphyre
Copy link
Member Author

I think this looks fine, especially the test case gives me confidence that this is the right thing to do +1

Me too - that's why we write tests haha

@sighphyre sighphyre merged commit 808db80 into main May 18, 2023
@sighphyre sighphyre deleted the fix/multiple-tokens-at-startup branch May 18, 2023 12:50
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