feat: Add Config#with_wrapper_information - #421
Open
kinyoklion wants to merge 1 commit into
Open
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Adds
Config#with_wrapper_informationso wrapper libraries can derive a configuration that identifies themselves without reconstructing the application's configuration.wrapper_nameandwrapper_versionreplaced; the original is unchanged.Configuration.Builder(config)) and Java (LDConfig.Builder.fromConfig) SDKs.Config.Implementation details
Requirements
Related issues
The Ruby OpenFeature provider accepts a
LaunchDarkly::Configfrom the application and needs to add wrapper identification to it.Configexposeswrapper_name/wrapper_versionas readers only, so today a wrapper would have to either mutate instance variables or rebuild the configuration option by option, which silently drops any options it does not know about.Describe the solution you've provided
with_wrapper_information(wrapper_name, wrapper_version = nil)usesdupplus protected writers for the two wrapper fields, so all other configuration — including options added in the future — carries over unchanged.Describe alternatives you've considered
Reconstructing a
Configfrom the public readers — rejected because it must be updated whenever a configuration option is added and would drop unknown options. Public writers for the wrapper fields — rejected becauseConfigis otherwise immutable after construction.Testing
bundle exec rspecon Ruby 3.4: 1027 examples, 0 failures.bundle exec rubocopon the changed files: no offenses. Theprotected attr_writerform was also verified on Ruby 3.1, the minimum supported version.@cursor review
Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion
Note
Overview
Adds
Config#with_wrapper_information(wrapper_name, wrapper_version = nil)so wrapper libraries (e.g. the Ruby OpenFeature provider) can derive a config that reports their own wrapper identity in User-Agent headers without rebuilding the app’sConfigfrom public readers.The method
dups the config, updateswrapper_nameandwrapper_versionvia new protected writers, and leaves the original unchanged.wrapper_versiondefaults tonilwhen omitted.Specs cover updated wrapper fields, preservation of other options (e.g.
offline?), no mutation of the source config, and the defaultwrapper_versionbehavior.Reviewed by Cursor Bugbot for commit 619ad78. Bugbot is set up for automated code reviews on this repo. Configure here.