Skip to content

Commit

Permalink
feat: Expose CreateChannel in ClientBuilderBase
Browse files Browse the repository at this point in the history
We either need to expose this or the GrpcAdapter.CreateChannel method; this feels more contained for now.
  • Loading branch information
jskeet committed Apr 25, 2022
1 parent f257160 commit 385b63f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void ResetChannelCreation()
ChannelCreated = null;
}

private protected override ChannelBase CreateChannel(string endpoint, ChannelCredentials credentials)
protected override ChannelBase CreateChannel(string endpoint, ChannelCredentials credentials)
{
CredentialsUsedToCreateChannel = credentials;
EndpointUsedToCreateChannel = endpoint;
Expand Down
14 changes: 13 additions & 1 deletion Google.Api.Gax.Grpc/ClientBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,19 @@ public async Task<TClient> BuildAsync(IServiceProvider provider, CancellationTok
return await BuildAsync(cancellationToken).ConfigureAwait(false);
}

private protected virtual ChannelBase CreateChannel(string endpoint, ChannelCredentials credentials) =>
/// <summary>
/// Returns a <see cref="ChannelBase"/> as created by <see cref="EffectiveGrpcAdapter"/>
/// for the specified endpoint and credentials, using the gRPC channel options from
/// <see cref="GetChannelOptions"/>.
/// </summary>
/// <remarks>
/// This is only useful in very specific situations where a known channel is required;
/// <see cref="CreateCallInvoker"/> and its async equivalent are more usually useful.
/// </remarks>
/// <param name="endpoint">The endpoint of the channel.</param>
/// <param name="credentials">The channel credentials.</param>
/// <returns>The channel created by the gRPC adapter.</returns>
protected virtual ChannelBase CreateChannel(string endpoint, ChannelCredentials credentials) =>
EffectiveGrpcAdapter.CreateChannel(ServiceMetadata, endpoint, credentials, GetChannelOptions());

private class DelegatedTokenAccess : ITokenAccessWithHeaders
Expand Down

0 comments on commit 385b63f

Please sign in to comment.