Skip to content
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

feat: Modify the refresh window to match go/async-token-refresh. Serverless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window. #1352

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

clundin25
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

…erless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window.
@@ -68,7 +68,7 @@
public class OAuth2Credentials extends Credentials {

private static final long serialVersionUID = 4556936364828217687L;
static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(5);
static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(3).plusSeconds(45);
static final Duration DEFAULT_REFRESH_MARGIN = Duration.ofMinutes(6);
Copy link
Member

@TimurSadykov TimurSadykov Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to change both? This to 4 mins or slightly below and expiration to below 3min.

Right now it will start refreshing at 6 mins and get insta cached response for next 2 mins.

Copy link
Member

@TimurSadykov TimurSadykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comment on changing both values

@clundin25
Copy link
Contributor Author

Left comment on changing both values

Good point. I have revised the change

Copy link

sonarcloud bot commented Jan 11, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@TimurSadykov TimurSadykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@TimurSadykov TimurSadykov merged commit a7a8d7a into googleapis:main Jan 11, 2024
17 checks passed
@TimurSadykov
Copy link
Member

@clundin25 Hey sorry for the late comment... but it looks like those margins aren't covered with tests, could you please add those? There are margin related tests in ComputeCredentialTests

@clundin25
Copy link
Contributor Author

@TimurSadykov
Copy link
Member

@clundin25 it is a bit more than a getter validation. The test you highlighted validates that compute credentials has their specific margins set. As i understand similar tests are missing for other credentials that supposed to use defaults. It could be that custom margins set up for some credentials and its a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants