-
Notifications
You must be signed in to change notification settings - Fork 64
feat: Parse Host Service Name #2300
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
629dee4
refactor: Add transportchannelprovider's endpoint to EndpointContext
lqiu96 a709d8a
chore: Add Endpoint tests for ClientContext
lqiu96 e227b62
chore: Resolve PR comments
lqiu96 c6c59a6
feat: Add HostServiceName to StubSettings
lqiu96 789d4e2
chore: Add comments for hostservicename
lqiu96 309d598
chore: Fix setEndpoint logic
lqiu96 4d84c02
chore: Add InternalApi annotation to setDefaultHost in StubSettings
lqiu96 3adeee4
fix: Expose HostServiceName in ClientContext
lqiu96 3e62052
chore: Add comments for hostservicename
lqiu96 d07ed96
chore: Set hostServiceName to package private scope
lqiu96 db04a0b
chore: Update integration tests
lqiu96 09a5dfd
chore: Resolve PR comments
lqiu96 3df71f4
chore: Do not generate getServiceName if hostServiceName is empty
lqiu96 a3e27e7
chore: Add tests for parsing Host Service Name
lqiu96 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
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
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
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
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import com.google.api.core.ApiClock; | ||
import com.google.api.core.ApiFunction; | ||
import com.google.api.core.BetaApi; | ||
import com.google.api.core.InternalApi; | ||
import com.google.api.core.NanoClock; | ||
import com.google.api.gax.core.CredentialsProvider; | ||
import com.google.api.gax.core.ExecutorProvider; | ||
|
@@ -70,6 +71,7 @@ public abstract class StubSettings<SettingsT extends StubSettings<SettingsT>> { | |
private final HeaderProvider internalHeaderProvider; | ||
private final TransportChannelProvider transportChannelProvider; | ||
private final ApiClock clock; | ||
private final String serviceName; | ||
private final String endpoint; | ||
private final String mtlsEndpoint; | ||
private final String quotaProjectId; | ||
|
@@ -96,6 +98,7 @@ protected StubSettings(Builder builder) { | |
this.headerProvider = builder.headerProvider; | ||
this.internalHeaderProvider = builder.internalHeaderProvider; | ||
this.clock = builder.clock; | ||
this.serviceName = builder.serviceName; | ||
this.endpoint = builder.endpoint; | ||
this.mtlsEndpoint = builder.mtlsEndpoint; | ||
this.switchToMtlsEndpointAllowed = builder.switchToMtlsEndpointAllowed; | ||
|
@@ -137,6 +140,13 @@ public final ApiClock getClock() { | |
return clock; | ||
} | ||
|
||
// Intended for Internal Use and Overriden by generated ServiceStubSettings classes. | ||
// Meant to be shared between StubSettings and ClientContext. | ||
@InternalApi | ||
public String getServiceName() { | ||
return ""; | ||
} | ||
Comment on lines
+143
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public final String getEndpoint() { | ||
return endpoint; | ||
} | ||
|
@@ -211,6 +221,7 @@ public abstract static class Builder< | |
private HeaderProvider internalHeaderProvider; | ||
private TransportChannelProvider transportChannelProvider; | ||
private ApiClock clock; | ||
private String serviceName; | ||
private String endpoint; | ||
private String mtlsEndpoint; | ||
private String quotaProjectId; | ||
|
@@ -236,6 +247,7 @@ protected Builder(StubSettings settings) { | |
this.headerProvider = settings.headerProvider; | ||
this.internalHeaderProvider = settings.internalHeaderProvider; | ||
this.clock = settings.clock; | ||
this.serviceName = settings.serviceName; | ||
this.endpoint = settings.endpoint; | ||
this.mtlsEndpoint = settings.mtlsEndpoint; | ||
this.switchToMtlsEndpointAllowed = settings.switchToMtlsEndpointAllowed; | ||
|
@@ -272,6 +284,7 @@ protected Builder(ClientContext clientContext) { | |
this.headerProvider = new NoHeaderProvider(); | ||
this.internalHeaderProvider = new NoHeaderProvider(); | ||
this.clock = NanoClock.getDefaultClock(); | ||
this.serviceName = null; | ||
this.endpoint = null; | ||
this.mtlsEndpoint = null; | ||
this.quotaProjectId = null; | ||
|
@@ -292,6 +305,7 @@ protected Builder(ClientContext clientContext) { | |
this.internalHeaderProvider = | ||
FixedHeaderProvider.create(clientContext.getInternalHeaders()); | ||
this.clock = clientContext.getClock(); | ||
this.serviceName = clientContext.getServiceName(); | ||
this.endpoint = clientContext.getEndpoint(); | ||
if (this.endpoint != null) { | ||
this.mtlsEndpoint = this.endpoint.replace("googleapis.com", "mtls.googleapis.com"); | ||
|
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
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
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 know we are already testing this method indirectly through golden tests. Since this is in Service not composers, and we can easily mock the input, it would be great if we can have unit tests testing it directly as well.
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.
Added some tests for parsing, thanks!