Skip to content

Commit

Permalink
xds: move tlsContextManager (grpc#10859)
Browse files Browse the repository at this point in the history
Minor refactor to the tlsContextManager to not expose itself on the xdsClientImpl constructor.
This is to allow people who plugins xdsTransportFactory to use the API easily.
  • Loading branch information
YifeiZhuang authored Jan 30, 2024
1 parent c2a3792 commit 20abea4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import io.grpc.internal.TimeProvider;
import io.grpc.xds.Bootstrapper.BootstrapInfo;
import io.grpc.xds.XdsNameResolverProvider.XdsClientPoolFactory;
import io.grpc.xds.internal.security.TlsContextManagerImpl;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -130,8 +129,7 @@ public XdsClient getObject() {
scheduler,
new ExponentialBackoffPolicy.Provider(),
GrpcUtil.STOPWATCH_SUPPLIER,
TimeProvider.SYSTEM_TIME_PROVIDER,
new TlsContextManagerImpl(bootstrapInfo));
TimeProvider.SYSTEM_TIME_PROVIDER);
}
refCount++;
return xdsClient;
Expand Down
6 changes: 3 additions & 3 deletions xds/src/main/java/io/grpc/xds/XdsClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import io.grpc.xds.XdsClient.TimerLaunch;
import io.grpc.xds.XdsClient.XdsResponseHandler;
import io.grpc.xds.XdsLogger.XdsLogLevel;
import io.grpc.xds.internal.security.TlsContextManagerImpl;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -116,16 +117,15 @@ public void uncaughtException(Thread t, Throwable e) {
ScheduledExecutorService timeService,
BackoffPolicy.Provider backoffPolicyProvider,
Supplier<Stopwatch> stopwatchSupplier,
TimeProvider timeProvider,
TlsContextManager tlsContextManager) {
TimeProvider timeProvider) {
this.xdsTransportFactory = xdsTransportFactory;
this.bootstrapInfo = bootstrapInfo;
this.context = context;
this.timeService = timeService;
this.backoffPolicyProvider = backoffPolicyProvider;
this.stopwatchSupplier = stopwatchSupplier;
this.timeProvider = timeProvider;
this.tlsContextManager = checkNotNull(tlsContextManager, "tlsContextManager");
this.tlsContextManager = new TlsContextManagerImpl(bootstrapInfo);
logId = InternalLogId.allocate("xds-client", null);
logger = XdsLogger.withLogId(logId);
logger.log(XdsLogLevel.INFO, "Created");
Expand Down
8 changes: 2 additions & 6 deletions xds/src/test/java/io/grpc/xds/XdsClientImplTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ public long currentTimeNanos() {
private ResourceWatcher<CdsUpdate> cdsResourceWatcher;
@Mock
private ResourceWatcher<EdsUpdate> edsResourceWatcher;
@Mock
private TlsContextManager tlsContextManager;

private ManagedChannel channel;
private ManagedChannel channelForCustomAuthority;
Expand Down Expand Up @@ -374,8 +372,7 @@ public XdsTransport create(ServerInfo serverInfo) {
fakeClock.getScheduledExecutorService(),
backoffPolicyProvider,
fakeClock.getStopwatchSupplier(),
timeProvider,
tlsContextManager);
timeProvider);

assertThat(resourceDiscoveryCalls).isEmpty();
assertThat(loadReportCalls).isEmpty();
Expand Down Expand Up @@ -3749,8 +3746,7 @@ private XdsClientImpl createXdsClient(String serverUri) {
fakeClock.getScheduledExecutorService(),
backoffPolicyProvider,
fakeClock.getStopwatchSupplier(),
timeProvider,
tlsContextManager);
timeProvider);
}

private BootstrapInfo buildBootStrap(String serverUri) {
Expand Down

0 comments on commit 20abea4

Please sign in to comment.