Repository navigation
feat: Let each data source decide whether FDv2 writes its data to a persistent store #389
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
Merged
+1,031
−44
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d79a074
feat: Let each data source decide whether FDv2 writes its data to a p…
kinyoklion 80d3f98
fix: Track the most recent persistence indicator for store recovery
kinyoklion 982d5c9
fix: Keep file and test data out of the store when another configurer…
kinyoklion ce030b4
refactor: Take the persistence declaration of an FDv2 change set from…
kinyoklion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
pkgs/sdk/server/src/Internal/DataSystem/IDataSourcePersistence.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| namespace LaunchDarkly.Sdk.Server.Internal.DataSystem | ||
| { | ||
| /// <summary> | ||
| /// Implemented by a data source configurer that states whether the FDv2 data system may write the | ||
| /// source's data to a persistent store. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The data system reads this when it builds the source, and applies it to every full data set and | ||
| /// every upsert that the source delivers. A configurer that does not implement this interface | ||
| /// produces data that is persisted. The FDv1 data system does not use this: there, the data store | ||
| /// receives all data. | ||
| /// </remarks> | ||
| internal interface IDataSourcePersistence | ||
| { | ||
| /// <summary> | ||
| /// True if the data system may write the data from the sources built by this configurer to a | ||
| /// persistent store. | ||
| /// </summary> | ||
| bool ShouldPersist { get; } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
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 there an obvious argument for doing it this way and not the inverse? The inverse being a sources not implementing the interface defaults to persist and sources must implement and opt out of persist?
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.
This reply was written by an AI agent (Claude Code) working on behalf of @kinyoklion.
The code is that inverse: a configurer that does not implement
IDataSourcePersistenceis persisted, and a source opts out by implementing it. The file data source and test data implement it and default toShouldPersist(false).The reason is in the data system spec. DATASYSTEM v2 Requirement 1.1.7 says initializers MUST indicate whether data persistence is requested via the
persistfield of a returned Basis, and Requirement 1.2.8 says the same of synchronizers for a Basis or a Delta. The motivation under 1.1.7 is that not all data should be mirrored to a persistent store, only data that is "trusted" or "authoritative", and its examples are a file initializer that setspersist = falseand a polling initializer that setspersist = true.So the sources that carry local, non-authoritative data declare that they do not persist: the file data source, which the spec names, and test data, which is local data of the same kind. Everything else keeps persisting without having to declare anything: the FDv2 streaming and polling sources, the FDv1 fallback synchronizer, whose data also comes from LaunchDarkly, and a custom data source written against the existing
IDataSourceAPI, whose data the SDK always wrote to the store before this change. Defaulting the other way would make each of those opt in, and a custom source that predates the interface would silently stop being persisted.