Repository navigation
fix: Use the server's FDv1 fallback TTL from the header and goodbye #278
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
beekld
wants to merge
3
commits into
main
Choose a base branch
from
devin/1795126798-server-fallback-ttl
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.
+457
−200
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ee51082
fix: Use the server's FDv1 fallback TTL from the header and goodbye
devin-ai-integration[bot] 71beeaa
refactor: Carry the FDv1 fallback directive as a nullable FDv1Fallback
devin-ai-integration[bot] a4151c3
Merge origin/main into devin/1795126798-server-fallback-ttl
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
20 changes: 19 additions & 1 deletion
20
lib/sdk/server/src/main/java/com/launchdarkly/sdk/server/HeaderConstants.java
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
30 changes: 30 additions & 0 deletions
30
lib/sdk/server/src/main/java/com/launchdarkly/sdk/server/datasources/FDv1Fallback.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.launchdarkly.sdk.server.datasources; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| /** | ||
| * This type is currently experimental and not subject to semantic versioning. | ||
| * <p> | ||
| * A server directive to fall back to FDv1. | ||
| */ | ||
| public final class FDv1Fallback { | ||
| private final Duration ttl; | ||
|
|
||
| /** | ||
| * Creates a fallback directive with the server-provided TTL. | ||
| * | ||
| * @param ttl the TTL, or null if the server gave none | ||
| */ | ||
| public FDv1Fallback(Duration ttl) { | ||
| this.ttl = ttl; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the server-provided TTL. | ||
| * | ||
| * @return the TTL, or null if the server gave none | ||
| */ | ||
| public Duration getTtl() { | ||
| return ttl; | ||
| } | ||
| } | ||
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.
This is probably fine in server, but we did recently make a PR to change one of these in internal or common. Because it isn't in the android API level that we use. But I wonder if we want to just not use java.time.Duration, or we just avoid it in the common libraries.
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.
This is only in the server SDK, which already uses
java.time.Durationin 33 main source files onmain, including the existingdefaultFDv1FallbackTTL. The goodbye TTL comes from the internal lib as nullableLongmillis, as of #273, and is converted to aDurationonly here. As far as I can tell,lib/shared/commonandlib/shared/internalhave nojava.time.Durationleft. So "avoid it in the common libraries" seems to be the rule today, and this PR follows it. I'll leave it as is unless you'd like the server SDK to avoid it too.Written by Devin
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.
aside: I've seen so many bugs from code that disagreed about whether a
Longwas seconds or millis, I'm inclined to useDurationwhere we can. But I know we don't want to require desugaring in Android, so... well, I'll deal either way.