fix: Wait for the data source when no start wait time is configured - #36
Draft
kinyoklion wants to merge 1 commit into
Draft
fix: Wait for the data source when no start wait time is configured#36kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
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 |
3 tasks
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.
Initialization no longer fails immediately when the provider is constructed with a wait time of zero.
initran while the data source was stillINITIALIZINGand reported a failed initialization even though the connection was about to succeed.initnow waits for the data source to become valid or to fail permanently when the wait time is zero, and keeps its existing behavior for a positive wait time, which the client constructor has already applied.Found during the weekly OpenFeature provider audit.
Implementation details
Requirements
Related issues
None.
Describe the solution you've provided
The provider keeps the wait time it was constructed with. When it is zero,
initsubscribes aDataSourceOutcomeListenerto the data source status provider, then checks whether the client is already initialized or the data source is alreadyOFFbefore blocking on a queue, so an outcome reached between construction and subscription is not missed. The listener is removed once an outcome arrives.VALIDandOFFare the states which decide the outcome;INITIALIZINGandINTERRUPTEDleave the client still trying, so they do not end the wait.Whether initialization succeeded is still decided by
initialized?, and a failure still raises, which the OpenFeature SDK turns into theERRORstate.Describe alternatives you've considered
Applying a default timeout when the wait time is zero: zero is the caller asking for no deadline, and the OpenFeature SDK is what decides how long to wait for a provider.
Polling
initialized?: the data source status provider already reports transitions, so polling would only add latency and wake-ups.Additional context
Testing:
bundle exec rspec(79 examples) andbundle exec rubocopon Ruby 3.4.5. The new tests cover a zero wait time succeeding once the data source becomes valid, a zero wait time waiting for an outcome which arrives afterinitis called, a positive wait time not waiting a second time, and the outcome listener's per-state behavior.The README's Initialization row describes the zero wait time behavior.
Link to Devin session: https://app.devin.ai/sessions/fe1eb757fe694ef79f3d09f6307d4b47
Open in Devin Desktop: https://app.devin.ai/desktop/session/fe1eb757fe694ef79f3d09f6307d4b47?variant=devin
Requested by: @kinyoklion