-
Notifications
You must be signed in to change notification settings - Fork 3
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: Identity overrides in local evaluation mode #20
Conversation
f04ee89
to
c2ab95c
Compare
environment_url.clone(), | ||
)?); | ||
for identity in &environment.as_ref().unwrap().identity_overrides { | ||
data.identities_with_overrides_by_identifier.insert(identity.identifier.clone(), identity.clone()); |
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.
I'll happily accept pointers on how to stop copying around the identity structs. This shouldn't be a problem for most environments, but we need to be aware there's room for optimisation 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.
Added a couple of minor comments but they're likely mostly down to my limited knowledge of the Rust language.
src/flagsmith/mod.rs
Outdated
); | ||
let mut data = ds.lock().unwrap(); | ||
data.environment = environment; | ||
update_environment(&client, &ds, &environment_url).unwrap(); |
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.
Interested to know why we use client.clone()
above but directly point to the client
here.
I suspect it's because we want to update the environment on the instance of the client itself, but just double checking.
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.
I'm not sure if cloning inside a loop is a good idea.
We're keeping the initial client instance for the background task, and cloning it once for the SDK client's blocking calls.
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.
I don't see obvious show stoppers, but I have a few small questions. I'm going to leave the final approval up to @matthewelwell since my experience with Rust is quite limited.
"api_key": "B62qaMZNwfiqT76p38ggrQ", | ||
"project": { |
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.
Feels kinda icky to have ENVIRONMENT_JSON
in this rust file. Can we not load it from a json file?
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 surprisingly verbose, see https://stackoverflow.com/questions/66340266/generating-constants-ar-compile-time-from-file-content
src/flagsmith/mod.rs
Outdated
|
||
// When | ||
let mut _flagsmith = Flagsmith::new(environment_key.to_string(), flagsmith_options); | ||
thread::sleep(std::time::Duration::from_millis(250)); |
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 this sleep necessary to allow the local evaluation document to be ready and loaded? In other words, if we don't sleep do we have an empty document? If so, we should rework the blocking logic and block on boot for the first local evaluation like we currently do in the Python client.
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.
Good catch, fixed this!
946e4e0
to
1f338a2
Compare
Closes #17.
Contributes to Flagsmith/flagsmith#3132.
Changes:
update_environment
to share code between theFlagsmith.update_environment
interface and the threaded routineflagsmith-flag-engine
dependency spec will be changed after Flagsmith/flagsmith-rust-flag-engine#12 is merged and released.