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: update rest option to use newHttpJsonBuilder #9

Open
wants to merge 2 commits into
base: multi-module-w-shared
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public CredentialsProvider languageServiceCredentials() throws IOException { //
@Bean
@ConditionalOnMissingBean(name = "defaultLanguageTransportChannelProvider")
public TransportChannelProvider defaultLanguageTransportChannelProvider() {
if (clientProperties.isUseRest()) {
return LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build();
}
return LanguageServiceSettings.defaultTransportChannelProvider();
}

Expand All @@ -100,8 +103,16 @@ public LanguageServiceClient languageServiceClient(@Qualifier("languageServiceCr
@Qualifier("defaultLanguageTransportChannelProvider") TransportChannelProvider defaultTransportChannelProvider)
throws IOException {

LanguageServiceSettings.Builder clientSettingsBuilder =
LanguageServiceSettings.newBuilder()
LanguageServiceSettings.Builder clientSettingsBuilder;

if (clientProperties.isUseRest()) {
// To use REST (HTTP1.1/JSON) transport (instead of gRPC)
clientSettingsBuilder = LanguageServiceSettings.newHttpJsonBuilder();
} else {
clientSettingsBuilder = LanguageServiceSettings.newBuilder();
}

clientSettingsBuilder
.setCredentialsProvider(credentialsProvider)
// default transport channel provider, allow user to override bean for example to configure a proxy
// https://github.com/googleapis/google-cloud-java#configuring-a-proxy
Expand Down Expand Up @@ -132,13 +143,6 @@ public LanguageServiceClient languageServiceClient(@Qualifier("languageServiceCr
.setBackgroundExecutorProvider(executorProvider);
}

// To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
// can set a property to enable this if specified, but seems too niche usecase?
if (clientProperties.isUseRest()) {
clientSettingsBuilder.setTransportChannelProvider(
LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build());
}

// Retry Settings: set for each method.
// Useful settings for users. should expose settings for each method.
// If property not set, set to default -- need to access from gapic-context for each method.
Expand Down