Skip to content

Commit 0e4ed46

Browse files
Refactoring to allow multiple transports in GAPIC clients (googleapis#2156)
1 parent 6bd2e32 commit 0e4ed46

File tree

112 files changed

+8494
-3609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+8494
-3609
lines changed

google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import com.google.api.client.http.HttpResponseException;
2020
import com.google.api.core.InternalApi;
21-
import com.google.api.gax.grpc.ApiException;
21+
import com.google.api.gax.grpc.GrpcApiException;
2222
import com.google.cloud.BaseServiceException;
2323
import com.google.common.base.MoreObjects;
2424
import java.io.IOException;
@@ -64,13 +64,13 @@ private static ExceptionData makeExceptionData(IOException exception, boolean id
6464
.build();
6565
}
6666

67-
public BaseGrpcServiceException(ApiException apiException) {
67+
public BaseGrpcServiceException(GrpcApiException apiException) {
6868
super(ExceptionData.newBuilder()
6969
.setMessage(apiException.getMessage())
7070
.setCause(apiException)
7171
.setRetryable(apiException.isRetryable())
72-
.setCode(apiException.getStatusCode().value())
73-
.setReason(apiException.getStatusCode().name())
72+
.setCode(apiException.getStatusCode().getCode().value())
73+
.setReason(apiException.getStatusCode().getCode().name())
7474
.setLocation(null)
7575
.setDebugInfo(null)
7676
.build());

google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
import static com.google.common.base.MoreObjects.firstNonNull;
2020

2121
import com.google.api.core.InternalApi;
22-
import com.google.api.gax.core.FixedCredentialsProvider;
2322
import com.google.api.gax.core.CredentialsProvider;
2423
import com.google.api.gax.core.GaxProperties;
24+
import com.google.api.gax.core.FixedCredentialsProvider;
2525
import com.google.api.gax.core.NoCredentialsProvider;
2626
import com.google.api.gax.grpc.ChannelProvider;
2727
import com.google.api.gax.grpc.GaxGrpcProperties;
2828
import com.google.api.gax.grpc.InstantiatingChannelProvider;
29-
import com.google.api.gax.grpc.UnaryCallSettings;
3029
import com.google.api.gax.retrying.RetrySettings;
30+
import com.google.api.gax.rpc.UnaryCallSettings;
3131
import com.google.auth.Credentials;
3232
import com.google.cloud.NoCredentials;
3333
import com.google.cloud.ServiceOptions;
@@ -181,8 +181,9 @@ public ExecutorFactory<ScheduledExecutorService> getExecutorFactory() {
181181
/**
182182
* Returns a builder for API call settings.
183183
*/
184+
@Deprecated
184185
public UnaryCallSettings.Builder getApiCallSettings(RetrySettings retrySettings) {
185-
return UnaryCallSettings.newBuilder().setRetrySettingsBuilder(retrySettings.toBuilder());
186+
return UnaryCallSettings.newUnaryCallSettingsBuilder().setRetrySettings(retrySettings);
186187
}
187188

188189
/**
@@ -193,10 +194,6 @@ public static ChannelProvider setUpChannelProvider(
193194
providerBuilder.setEndpoint(serviceOptions.getHost())
194195
.setClientLibHeader(ServiceOptions.getGoogApiClientLibName(),
195196
firstNonNull(serviceOptions.getLibraryVersion(), ""));
196-
Credentials scopedCredentials = serviceOptions.getScopedCredentials();
197-
if (scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()) {
198-
providerBuilder.setCredentialsProvider(FixedCredentialsProvider.create(scopedCredentials));
199-
}
200197
return providerBuilder.build();
201198
}
202199

google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import static org.junit.Assert.assertNull;
2626
import static org.junit.Assert.assertTrue;
2727

28-
import com.google.api.gax.grpc.ApiException;
28+
import com.google.api.gax.grpc.GrpcApiException;
2929
import com.google.cloud.BaseServiceException;
3030
import com.google.cloud.RetryHelper;
3131
import io.grpc.Status.Code;
@@ -73,7 +73,8 @@ public void testBaseServiceException() {
7373
assertNull(serviceException.getDebugInfo());
7474

7575
Exception cause = new IllegalArgumentException("bad arg");
76-
ApiException apiException = new ApiException(MESSAGE, cause, Code.INTERNAL, NOT_RETRYABLE);
76+
GrpcApiException apiException =
77+
new GrpcApiException(MESSAGE, cause, Code.INTERNAL, NOT_RETRYABLE);
7778
serviceException = new BaseGrpcServiceException(apiException);
7879
assertFalse(serviceException.isRetryable());
7980
assertEquals(MESSAGE, serviceException.getMessage());

0 commit comments

Comments
 (0)