diff --git a/Google.Api.Gax.Grpc/ClientBuilderBase.cs b/Google.Api.Gax.Grpc/ClientBuilderBase.cs index 643c3b55..a978f8dc 100644 --- a/Google.Api.Gax.Grpc/ClientBuilderBase.cs +++ b/Google.Api.Gax.Grpc/ClientBuilderBase.cs @@ -462,7 +462,12 @@ internal async Task GetGoogleCredentialAsync(CancellationToken /// protected abstract ChannelPool GetChannelPool(); - private GrpcAdapter EffectiveGrpcAdapter => GrpcAdapter ?? GrpcAdapter.GetFallbackAdapter(ServiceMetadata); + /// + /// Returns the effective for this builder, + /// using the property if that is set, or the appropriate fallback adapter + /// for otherwise. + /// + protected GrpcAdapter EffectiveGrpcAdapter => GrpcAdapter ?? GrpcAdapter.GetFallbackAdapter(ServiceMetadata); /// /// Returns the options to use when creating a channel, taking diff --git a/Google.Api.Gax.Grpc/Gcp/GcpCallInvoker.cs b/Google.Api.Gax.Grpc/Gcp/GcpCallInvoker.cs index b2a86801..e07419af 100644 --- a/Google.Api.Gax.Grpc/Gcp/GcpCallInvoker.cs +++ b/Google.Api.Gax.Grpc/Gcp/GcpCallInvoker.cs @@ -20,7 +20,7 @@ namespace Google.Api.Gax.Grpc.Gcp /// Call invoker which can fan calls out to multiple underlying channels /// based on request properties. /// - internal sealed class GcpCallInvoker : CallInvoker + public sealed class GcpCallInvoker : CallInvoker { private static int s_clientChannelIdCounter; @@ -41,7 +41,7 @@ internal sealed class GcpCallInvoker : CallInvoker private readonly ServiceMetadata _serviceMetadata; /// - /// Initializes a new instance of the class. + /// Initializes a new instance. /// /// The metadata for the service that this call invoker will be used with. Must not be null. /// Target of the underlying grpc channels. Must not be null. @@ -49,7 +49,7 @@ internal sealed class GcpCallInvoker : CallInvoker /// Channel options to be used by the underlying grpc channels. Must not be null. /// The API config to apply. Must not be null. /// The adapter to use to create channels. Must not be null. - internal GcpCallInvoker(ServiceMetadata serviceMetadata, string target, ChannelCredentials credentials, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) + public GcpCallInvoker(ServiceMetadata serviceMetadata, string target, ChannelCredentials credentials, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) { _serviceMetadata = GaxPreconditions.CheckNotNull(serviceMetadata, nameof(serviceMetadata)); _target = GaxPreconditions.CheckNotNull(target, nameof(target)); diff --git a/Google.Api.Gax.Grpc/Gcp/GcpCallInvokerPool.cs b/Google.Api.Gax.Grpc/Gcp/GcpCallInvokerPool.cs index 5d50f51c..0b155f60 100644 --- a/Google.Api.Gax.Grpc/Gcp/GcpCallInvokerPool.cs +++ b/Google.Api.Gax.Grpc/Gcp/GcpCallInvokerPool.cs @@ -67,7 +67,7 @@ public Task ShutdownChannelsAsync() /// The API configuration used to determine channel keys. Must not be null. /// The gRPC adapter to use to create call invokers. Must not be null. /// A call invoker for the specified endpoint. - public CallInvoker GetCallInvoker(string endpoint, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) + public GcpCallInvoker GetCallInvoker(string endpoint, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) { GaxPreconditions.CheckNotNull(endpoint, nameof(endpoint)); var credentials = _credentialsCache.GetCredentials(); @@ -86,7 +86,7 @@ public CallInvoker GetCallInvoker(string endpoint, GrpcChannelOptions options, A /// The gRPC adapter to use to create call invokers. Must not be null. /// A task representing the asynchronous operation. The value of the completed /// task will be a call invoker for the specified endpoint. - public async Task GetCallInvokerAsync(string endpoint, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) + public async Task GetCallInvokerAsync(string endpoint, GrpcChannelOptions options, ApiConfig apiConfig, GrpcAdapter adapter) { GaxPreconditions.CheckNotNull(endpoint, nameof(endpoint)); GaxPreconditions.CheckNotNull(apiConfig, nameof(apiConfig)); diff --git a/Google.Api.Gax.Grpc/GrpcAdapter.cs b/Google.Api.Gax.Grpc/GrpcAdapter.cs index 3258b9a2..3fecb8c5 100644 --- a/Google.Api.Gax.Grpc/GrpcAdapter.cs +++ b/Google.Api.Gax.Grpc/GrpcAdapter.cs @@ -38,9 +38,8 @@ private protected GrpcAdapter(ApiTransports supportedTransports) _supportedTransports = supportedTransports; } - // TODO: potentially expose either or both of the methods below if we want, or a - // "get the first adapter that supports this service, from the following list, or a fallback" - // method. + // TODO: potentially expose this if we want, or a "get the first adapter that supports + // this service, from the following list, or a fallback" method. /// /// Returns whether or not this adapter supports the specified service. @@ -58,7 +57,7 @@ internal bool SupportsApi(ServiceMetadata serviceMetadata) /// /// The descriptor of the API. Must not be null. /// A suitable GrpcAdapter for the given API, preferring the use of the binary gRPC transport where available. - internal static GrpcAdapter GetFallbackAdapter(ServiceMetadata serviceMetadata) => + public static GrpcAdapter GetFallbackAdapter(ServiceMetadata serviceMetadata) => // TODO: Do we need some way of indicating a preference, if the service supports both Rest and Grpc? // Probably not: the user code can always specify the adapter in the builder serviceMetadata.Transports.HasFlag(ApiTransports.Grpc) ? s_defaultGrpcTransportFactory.Value