xds: move tlsContextManager (#10859)

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.
This commit is contained in:
yifeizhuang 2024-01-30 12:59:33 -08:00 committed by GitHub
parent c2a3792a04
commit 20abea47bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 12 deletions

View File

@ -28,7 +28,6 @@ import io.grpc.internal.SharedResourceHolder;
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;
@ -130,8 +129,7 @@ final class SharedXdsClientPoolProvider implements XdsClientPoolFactory {
scheduler,
new ExponentialBackoffPolicy.Provider(),
GrpcUtil.STOPWATCH_SUPPLIER,
TimeProvider.SYSTEM_TIME_PROVIDER,
new TlsContextManagerImpl(bootstrapInfo));
TimeProvider.SYSTEM_TIME_PROVIDER);
}
refCount++;
return xdsClient;

View File

@ -47,6 +47,7 @@ import io.grpc.xds.XdsClient.ResourceStore;
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;
@ -116,8 +117,7 @@ final class XdsClientImpl extends XdsClient
ScheduledExecutorService timeService,
BackoffPolicy.Provider backoffPolicyProvider,
Supplier<Stopwatch> stopwatchSupplier,
TimeProvider timeProvider,
TlsContextManager tlsContextManager) {
TimeProvider timeProvider) {
this.xdsTransportFactory = xdsTransportFactory;
this.bootstrapInfo = bootstrapInfo;
this.context = context;
@ -125,7 +125,7 @@ final class XdsClientImpl extends XdsClient
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");

View File

@ -287,8 +287,6 @@ public abstract class XdsClientImplTestBase {
private ResourceWatcher<CdsUpdate> cdsResourceWatcher;
@Mock
private ResourceWatcher<EdsUpdate> edsResourceWatcher;
@Mock
private TlsContextManager tlsContextManager;
private ManagedChannel channel;
private ManagedChannel channelForCustomAuthority;
@ -374,8 +372,7 @@ public abstract class XdsClientImplTestBase {
fakeClock.getScheduledExecutorService(),
backoffPolicyProvider,
fakeClock.getStopwatchSupplier(),
timeProvider,
tlsContextManager);
timeProvider);
assertThat(resourceDiscoveryCalls).isEmpty();
assertThat(loadReportCalls).isEmpty();
@ -3749,8 +3746,7 @@ public abstract class XdsClientImplTestBase {
fakeClock.getScheduledExecutorService(),
backoffPolicyProvider,
fakeClock.getStopwatchSupplier(),
timeProvider,
tlsContextManager);
timeProvider);
}
private BootstrapInfo buildBootStrap(String serverUri) {