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

fix: Make it explicit that there is a network call to MDS to get SecureSessionAgentConfig #1573

Merged
merged 7 commits into from
Nov 8, 2024

Conversation

rmehta19
Copy link
Contributor

@rmehta19 rmehta19 commented Nov 7, 2024

Make the classes non-final while we're here to allow for mocking in tests if needed.

@rmehta19 rmehta19 requested review from a team as code owners November 7, 2024 18:33
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Nov 7, 2024
Copy link

conventional-commit-lint-gcf bot commented Nov 7, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@@ -58,7 +58,7 @@
* <p>This is an experimental utility.
*/
@ThreadSafe
public final class S2A {
public class S2A {
Copy link
Contributor

Choose a reason for hiding this comment

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

On a second look, do you have concerns if we can make this name written out specifically (SecureSessionAgent.java) and (SecureSessionAgentConfig.java) as S2A may not be well known and specific to Google?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fine with me, done in e6b6e18

Comment on lines 84 to 87
/** @return the cached S2AConfig. */
public S2AConfig getConfigFromMDS() {
return config;
}
Copy link
Contributor

@lqiu96 lqiu96 Nov 7, 2024

Choose a reason for hiding this comment

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

What I had in mind was

public SecureSessionAgentConfig getConfig() {
  return getS2AConfigFromMDS();
}

as this getConfig() call is the explicit call that will make the network call.

Plus with javadocs that mention that this is a network call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, so right now the config is being set in the builder and is a member of the class. The current setup ensures that only one call to MDS is made (since there is no need to make the request to MDS multiple times) no matter how many times a user calls getConfigFromMds.

I'm fine with this though, it shifts responsibility to the user to store config and not call getConfig() more than once to save latency of their application. This seems aligned with what you mentioned in our offline discussion yesterday about how it should be explicit a network call is being made.

Done in: 381efe4

return config.getPlaintextAddress();
/** @return the cached S2AConfig. */
public S2AConfig getConfigFromMDS() {
return config;
}

public static Builder newBuilder() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if you want, you can include a static create() helper that creates a default instance (i.e. SecureSessionAgent.create()).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 7ce0291

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Nov 8, 2024
@rmehta19
Copy link
Contributor Author

rmehta19 commented Nov 8, 2024

Thanks for review @lqiu96 !

Copy link
Contributor

@lqiu96 lqiu96 left a comment

Choose a reason for hiding this comment

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

LGTM. Added a few nits/ questions

@lqiu96
Copy link
Contributor

lqiu96 commented Nov 8, 2024

@rmehta19 Also can you update the title with fix: {title}?

@rmehta19 rmehta19 changed the title Make it explicit that there is a call to MDS to get S2AConfig fix: Make it explicit that there is a call to MDS to get S2AConfig Nov 8, 2024
@rmehta19 rmehta19 changed the title fix: Make it explicit that there is a call to MDS to get S2AConfig fix: Make it explicit that there is a call to MDS to get SecureSessionAgentConfig Nov 8, 2024
@rmehta19 rmehta19 changed the title fix: Make it explicit that there is a call to MDS to get SecureSessionAgentConfig fix: Make it explicit that there is a network call to MDS to get SecureSessionAgentConfig Nov 8, 2024
@rmehta19
Copy link
Contributor Author

rmehta19 commented Nov 8, 2024

@lqiu96 , Thanks for the review! Addressed comments.

@lqiu96
Copy link
Contributor

lqiu96 commented Nov 8, 2024

@lqiu96 , Thanks for the review! Addressed comments.

LGTM. Let me know if you feel strongly about final/ non-final. I'll approve again and we can merge then

@lqiu96
Copy link
Contributor

lqiu96 commented Nov 8, 2024

FYI the linter is failing. I think you need to run mvn fmt:format again

@rmehta19
Copy link
Contributor Author

rmehta19 commented Nov 8, 2024

@lqiu96 , Thanks for the review! Addressed comments.

LGTM. Let me know if you feel strongly about final/ non-final. I'll approve again and we can merge then

As discussed offline, let's keep it final so that we can test it from Gax where it is used

Copy link

sonarcloud bot commented Nov 8, 2024

@lqiu96 lqiu96 merged commit 18020fe into googleapis:main Nov 8, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants