-
Notifications
You must be signed in to change notification settings - Fork 89
feat: add GrpcStorageOptions.Builder#setAttemptDirectPath #1688
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
Conversation
Add new builder method to all setting attempt of direct path connection. If enabled, the underlying gapic client will be configured to attempt connecting via direct path and using client side load balancing. deps: add a direct dependency to io.grpc:grpc-googleapis Rumour has it this dependency will be removed from gax, and we need to pull it up to our level to ensure it's there for storage direct path.
9d50191 to
f1aa593
Compare
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageOptions.java
Outdated
Show resolved
Hide resolved
|
|
||
| @BetaApi | ||
| public boolean isAttemptDirectPath() { | ||
| return false; |
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.
wait shouldn't this be a class property?
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 method is under GrpcStorageDefaults. And since it's the literal value of a boolean, doesn't need a constant to create a single instance.
| */ | ||
| @BetaApi | ||
| public GrpcStorageOptions.Builder setAttemptDirectPath(boolean attemptDirectPath) { | ||
| this.attemptDirectPath = attemptDirectPath; |
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.
Should this be enabled by default?
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.
With the latest version of gax-java an environment variable still needs to be set in order for direct path to actually be attempted. I think this type of thing we can change the default on in the future without there being an issue as long as there isn't any overhead to the attempt.
| endpoint = String.format("%s:%s", uri.getHost(), port > 0 ? port : 80); | ||
| break; | ||
| case "https": | ||
| endpoint = String.format("%s:%s", uri.getHost(), port > 0 ? port : 443); |
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.
Implementer's choice, just looking at alternative syntax to avoid the implicit-fallthrough default case:
private String resolveEndpoint(String originalEndpoint) {
URI uri = URI.create(originalEndpoint);
int defaultPort = scheme.equals("http") ? 80 : 443;
int explicitPort = uri.getPort();
int port = explicitPort > 0 ? explicitPort : defaultPort;
// Gax routes the endpoint into a method which can't handle schemes.
// Unless for direct path, try and strip here if we can.
return (schema.equals("http") || schema.equals("https"))
? String.format("%s:%s", uri.getHost(), port)
: originalEndpoint;
}
@InternalApi
StorageSettings getStorageSettings() throws IOException {
String endpoint = resolveEndpoint(getHost());
Add new builder method to all setting attempt of direct path connection.
If enabled, the underlying gapic client will be configured to attempt connecting via direct path and using client side load balancing.
deps: add a direct dependency to io.grpc:grpc-googleapis
Rumour has it this dependency will be removed from gax, and we need to pull it up to our level to ensure it's there for storage direct path.