feat: Configurably allow duplicates in FileDataSourceImpl#298
Open
djmorton42 wants to merge 1 commit intolaunchdarkly:mainfrom
Open
feat: Configurably allow duplicates in FileDataSourceImpl#298djmorton42 wants to merge 1 commit intolaunchdarkly:mainfrom
djmorton42 wants to merge 1 commit intolaunchdarkly:mainfrom
Conversation
This PR modifies the `FileDataSourceImpl` to accept an additional value in the options hash called `allow_duplicates`. `false` will be used if no value is provided which will cause this to operate exactly as it does prior to this change. Configuring `allow_duplicates` to be `true` will not raise an error when flag or segment values are loaded from multiple files and a subsequent file contains a key found in a previous file. The purpose of this is to allow a notion of a 'local' override during development. A project may have a `/config/feature_flags.yml` and a developer adds a flag to it for a feature they are developing. If they want to commit code with this feature, but don't want other developers encountering it yet, they will have to remember to turn the feature off prior to commiting their change. With this change, a project could have a `/config/feature_flags.yml` which contains the flag values other developers should see, and a `/config/feature_flags.local.yml` file, ignored by source control and not checked in. As a developer is working on the new feature, they can have it enabled in the `.local` file so they can see the feature and work with it, but disabled in the commited file so it does not impact other developers.
Member
|
Good afternoon, and thank you for this contribution! One of our goals when managing these SDKs is ensuring feature parity across all SDKs as much as possible. So modifying this behavior eventually requires propagating that change across many other SDKs. Before we go that route, I wanted to see if an alternative solution might be sufficient for your needs. We recently released a CLI tool called ldcli. Among its set of features is a local dev environment that allows developers to sync flag changes from any environment, but also provide some localized override capabilities. Do you think something like that might be sufficient for your teams needs? |
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.
Related issues
N/A
Describe the solution you've provided
This PR modifies the
FileDataSourceImplto accept an additional value in the options hash calledallow_duplicates.falsewill be used if no value is provided which will cause this to operate exactly as it does prior to this change.Configuring
allow_duplicatesto betruewill not raise an error when flag or segment values are loaded from multiple files and a subsequent file contains a key found in a previous file.The purpose of this is to allow a notion of a 'local' override during development. A project may have a
/config/feature_flags.ymland a developer adds a flag to it for a feature they are developing. If they want to commit code with this feature, but don't want other developers encountering it yet, they will have to remember to turn the feature off prior to commiting their change.With this change, a project could have a
/config/feature_flags.ymlwhich contains the flag values other developers should see, and a/config/feature_flags.local.ymlfile, ignored by source control and not checked in. As a developer is working on the new feature, they can have it enabled in the.localfile so they can see the feature and work with it, but disabled in the committed file so it does not impact other developers. As the files are processed in the order they are defined, the values defined in subsequent files would take precedence over duplicate values defined in prior files.Requirements
Describe alternatives you've considered
I considered trying to accomplish this via subclassing the
FileDataSourceImplbut it is not really designed for extension based on the amount of private functionality and state that it maintains internally. As such, an upstream change to the implementation itself seemed like the path of least resistance.Additional context