feat: Add support for test datasource#157
Merged
Conversation
Member
Author
|
Pending release of launchdarkly/rust-server-sdk-evaluation#33 |
0d05548 to
fccb5c4
Compare
kinyoklion
reviewed
Mar 3, 2026
| let inner = self.inner.lock(); | ||
| match inner.flag_origins.get(key) { | ||
| Some(FlagOrigin::Builder(builder)) => builder.clone(), | ||
| Some(FlagOrigin::Preconfigured) => { |
Member
There was a problem hiding this comment.
Would prefer fallthrough or hydration over this.
kinyoklion
reviewed
Mar 3, 2026
| /// Use this when you need to set a flag with a configuration that cannot be expressed through | ||
| /// [`FlagBuilder`](crate::FlagBuilder). The flag version is automatically managed. | ||
| /// | ||
| /// After calling this, you cannot use [`TestData::flag`] to get a builder for this flag key. |
Member
There was a problem hiding this comment.
This comment will need updated if/when we update the behavior.
kinyoklion
reviewed
Mar 3, 2026
|
|
||
| // Spawn a task to unregister the store on shutdown | ||
| let inner_ref = self.inner.clone(); | ||
| let store_ptr = Arc::as_ptr(&data_store) as *const () as usize; |
Member
There was a problem hiding this comment.
Feels excessively complex and gross.
kinyoklion
reviewed
Mar 3, 2026
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn use_preconfigured_segment_propagates() { |
Member
There was a problem hiding this comment.
Add a test to ensure preconfigured flags increment version.
Add a test equivalent to update_increments_version_each_call which validates the same behavior but using .flag
kinyoklion
approved these changes
Mar 3, 2026
…ured flags Instead of panicking when flag() is called on a key set via use_preconfigured_flag, fall through and return a new default FlagBuilder. Hydrating a builder from a Flag isn't feasible because FlagBuilder cannot represent all flag fields (prerequisites, migration settings, client visibility, etc.) and would silently lose data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the raw pointer cast chain (Arc::as_ptr as *const () as usize) with Arc::ptr_eq for comparing store instances during shutdown cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ilder Add use_preconfigured_flag_increments_version_each_call and flag_builder_increments_version_each_call to verify version auto-management works correctly across repeated updates for both code paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Medium Risk
Adds a new public
TestDatadata source and upgrades the evaluation crate, which can affect how flags/segments are versioned and propagated to client stores; overall scope is mostly additive and test-focused but touches core data-source wiring.Overview
Introduces a new
TestDatadata source that can be passed toConfigBuilder::data_sourceto inject and dynamically update flags/segments without any LaunchDarkly network connection, including automatic per-key version increments and propagation to all subscribed client stores.Exports
TestData(and evaluation builders likeFlagBuilder/RuleBuilder) fromlib.rs, bumpslaunchdarkly-server-sdk-evaluationto2.1.0, and refactorsclient.rstests to useTestDatainstead of manually upserting into the store (updating expected flag versions accordingly).Written by Cursor Bugbot for commit e00a3b9. This will update automatically on new commits. Configure here.