feat: Add environment ID support for hooks - #202
Draft
kinyoklion wants to merge 1 commit into
Draft
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:
|
Contributor
|
@cursor review |
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.
Requirements
Related issues
Companion to the equivalent work in the other SDKs: launchdarkly/python-server-sdk#484, launchdarkly/cpp-sdks#594, launchdarkly/ruby-server-sdk#414.
Describe the solution you've provided
EvaluationSeriesContextgains anenvironmentIdfield, populated from theX-LD-EnvIDresponse header LaunchDarkly sends on flag delivery responses.The value is latched into
DataSourceUpdatesImpland read back per evaluation through a supplier given toEvaluatorWithHooks, so it reflects the current data system state:Capture points:
DefaultFeatureRequestorrecords the header after the response is confirmed successful;PollingProcessorreports it to the update sink.StreamProcessorreads it from the message event headers.DataSourceUpdatesImpl.applynow latches it, but only once the data has been applied to the store successfully.DataSourceSynchronizerAdapterforwards the ID onto the change sets it synthesizes.Only non-empty values are latched, so a missing/empty header or an error response never clears a previously reported ID, and nothing is exposed before a successful response. The contract test service reports
environmentIdand declareshook-environment-id.Describe alternatives you've considered
Storing the ID as data store metadata (as dotnet-core does) — the change set already carries it here, so latching in the update sink keeps the existing architecture and covers FDv1, which has no change set.
Additional context
Verified against the released harnesses:
hooks/evaluation/provides the environment IDpasses on v2.39.0 (FDv1, default and polling) and v3.2.0-alpha.6 (FDv2). The repo's v3 contract test run is still pinned tov3.0.0-alpha.6, so it won't exercise the new test until that pin is bumped.Track hooks are not implemented in this SDK, so
TrackSeriesContextis unaffected.Link to Devin session: https://app.devin.ai/sessions/bfe54128e2804a96bb100e6120e9a3ef
Requested by: @kinyoklion