-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add a start wait timeout for initialization #61
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
Open
kinyoklion
wants to merge
7
commits into
main
Choose a base branch
from
devin/1787767004-java-start-wait
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+150
−8
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b5ce6a1
feat: Add a start wait timeout for initialization
devin-ai-integration[bot] a56a6f3
fix: Preserve configured Java start wait
devin-ai-integration[bot] 294a4a5
refactor: Reuse the wrapper config helper in the start wait constructor
devin-ai-integration[bot] b8e23e1
docs: Recommend bounded initialization waits
devin-ai-integration[bot] 095f4ea
fix: Resolve initialization immediately when a start wait was used
devin-ai-integration[bot] 70082f7
chore: Restore the generated version constant
devin-ai-integration[bot] 8862fe7
fix: Distinguish a permanent initialization failure from a lapsed sta…
devin-ai-integration[bot] 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
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.
I think Duration.Zero meaning wait indefinitely is not consistent with Duration.Zero passed to other SDKs startup/init/wait APIs. I think Duration.Zero is usually interpreted as don't wait at all.
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.
Zero here came from OFP 4.3.4.2 — "If the configured start wait time is zero, the provider MUST NOT apply an initialization timeout" — with the rationale that zero means the application does not want to block on initialization and leaves how long to wait up to the caller.
Worth separating the two layers, because I think my javadoc is what actually reads wrong:
LDConfig.startWait, so theLDClientconstructor returns immediately. That is the "don't wait at all" behavior you'd expect.initializeis invoked asynchronously by the OpenFeature API, so "no timeout" is not the application blocking forever — it means the provider does not fail initialization on a clock, and instead settles when the data source becomes valid or permanently fails. That is also the behavior onmaintoday for every existing caller.So the semantics follow the spec, but "waits indefinitely" is a misleading way to describe it, and if zero reads as "don't wait" to you it will read that way to users. Options, happy to take direction:
null, or a negative duration) and let zero mean fail immediately if not already ready — this diverges from OFP 4.3.4.2, so it would want a spec change rather than just a provider change.I'd lean towards 1 plus better docs, since the spec is cross-SDK, but you know the intent behind the wording better than I do. Which do you prefer?
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.
So, rephrasing it, we are saying:
This method will return immediately when the timeout is 0.
The time for the open feature initialized event itself is unbounded. It will be emitted when the SDK initializes or fails to initialize. If a timeout is provided, then an event will be emitted when the timeout lapses?
Or is it distinct from that?
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.
Close, with one correction on the first line — it's the constructor, not
initialize, that returns immediately.With
Duration.ZERO:Providerconstructor returns immediately. Zero goes toLDConfig.startWait, and the SDK checksisZero()/isNegative()and skips its wait on the data system future entirely.initializeis unbounded: it blocks on the data source status untilVALID(emitsPROVIDER_READY) orOFF(emitsPROVIDER_ERRORand throws). Nothing is emitted on a clock. Whether that blocks your thread is the OpenFeature API's choice, not the provider's —setProviderrunsinitializeon a background thread,setProviderAndWaitblocks.With a positive duration, both layers get it: the SDK constructor blocks up to that long, and
initializeadditionally stops waiting when it lapses, sets provider state toERROR, and throws — the OpenFeature SDK wraps that in aGeneralErrorand emitsPROVIDER_ERROR. So yes, an event on timeout, but as a failure rather than a separate timeout signal.One consequence worth a decision: the status listener stays registered after that throw, so if the data source becomes valid later, the provider still emits
PROVIDER_READYeven though initialization already failed. I think that's desirable — it's how the SDK recovers on its own — but it does mean the timeout bounds initialization, not the provider's lifetime. Say the word if you'd rather a lapsed timeout be terminal.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.
Following up on this after 095f4ea, since the behavior I described has changed: a positive duration is now spent once rather than twice. The SDK constructor blocks for up to
startWait, andinitializethen reports whatever the outcome already is instead of starting its own timed wait — so a two second start wait can no longer add up to four seconds of waiting. Zero still means no provider-applied timeout, per OFP 4.3.4.2, andinitializewaits until the data source is valid or permanently fails.The consequence I flagged above is unchanged: the status listener stays registered after a failed initialization, so a data source that becomes valid later still emits
PROVIDER_READY. Still happy to make a lapsed start wait terminal instead if that's what you'd prefer.