Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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 @@ -15,6 +15,7 @@
*/
package com.google.cloud.bigtable.data.v2.internal.compat;

import com.google.api.core.ApiFunction;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.auth.Credentials;
import com.google.bigtable.v2.FeatureFlags;
Expand All @@ -32,11 +33,15 @@
import javax.annotation.Nullable;

public class GaxBasicChannelProvider implements ChannelProvider {
private final ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator;
private final InstantiatingGrpcChannelProvider inner;
private final @Nullable CallCredentials credentials;

@SuppressWarnings("rawtypes")
public GaxBasicChannelProvider(
InstantiatingGrpcChannelProvider inner, @Nullable Credentials credentials) {
this.channelConfigurator =
Optional.ofNullable(inner.toBuilder().getChannelConfigurator()).orElse(b -> b);
this.inner = inner.toBuilder().setAttemptDirectPath(false).build();
this.credentials = Optional.ofNullable(credentials).map(MoreCallCredentials::from).orElse(null);
}
Expand All @@ -56,6 +61,7 @@ public ManagedChannelBuilder<?> newChannelBuilder() {
if (credentials != null) {
builder.intercept(new CredInterceptor(credentials));
}
builder = channelConfigurator.apply(builder);
return builder;
} catch (IOException e) {
throw new RuntimeException("Gax channel provider failed to provide a channel builder", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.bigtable.data.v2.internal.compat;

import com.google.api.core.ApiFunction;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.auth.Credentials;
import com.google.bigtable.v2.FeatureFlags;
Expand All @@ -26,6 +27,10 @@

public class GaxDirectAccessChannelProvider implements ChannelProvider {
private final InstantiatingGrpcChannelProvider inner;

@SuppressWarnings("rawtypes")
private final ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator;

private final Optional<ChannelProvider> fallback;

public static ChannelProvider create(
Expand Down Expand Up @@ -67,6 +72,9 @@ private GaxDirectAccessChannelProvider(
@SuppressWarnings("unused") @Nullable Credentials credentials,
Optional<ChannelProvider> fallback) {
this.inner = directAccessProvider;
this.channelConfigurator =
Optional.ofNullable(directAccessProvider.toBuilder().getChannelConfigurator())
.orElse(b -> b);
this.fallback = fallback;
}

Expand All @@ -81,7 +89,7 @@ public FeatureFlags updateFeatureFlags(FeatureFlags featureFlags) {
@Override
public ManagedChannelBuilder<?> newChannelBuilder() {
try {
return inner.createChannelBuilder();
return channelConfigurator.apply(inner.createChannelBuilder());
} catch (IOException e) {
throw new RuntimeException("Gax channel provider failed to provide a channel builder", e);
}
Expand Down
Loading