Skip to content

Commit 184d80a

Browse files
authored
Rename Grpc.NetCore.HttpClient to Grpc.Net.Client (#287)
1 parent ae2f95e commit 184d80a

File tree

52 files changed

+112
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+112
-132
lines changed

Grpc.AspNetCore.sln

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets",
9898
EndProject
9999
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkWorkerWebsite", "testassets\BenchmarkWorkerWebsite\BenchmarkWorkerWebsite.csproj", "{C3D6C3BD-4E56-4B0F-88FD-4F2D68F0CD25}"
100100
EndProject
101-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grpc.NetCore.HttpClient", "src\Grpc.NetCore.HttpClient\Grpc.NetCore.HttpClient.csproj", "{FA2EF163-D774-4A28-94D7-F0A5D1A11892}"
102-
EndProject
103101
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mailer", "examples\Clients\Mailer\Mailer.csproj", "{20B3B4DC-0BF1-406B-83EC-D105B6FA846A}"
104102
EndProject
105103
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Certs", "Certs", "{39320CA8-D8F0-45B6-B704-A04C16870226}"
@@ -120,8 +118,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reflector", "examples\Clien
120118
EndProject
121119
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropTestsClient", "testassets\InteropTestsClient\InteropTestsClient.csproj", "{291E5BA5-608D-406D-A2DB-389412D907F3}"
122120
EndProject
123-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grpc.NetCore.HttpClient.Tests", "test\Grpc.NetCore.HttpClient.Tests\Grpc.NetCore.HttpClient.Tests.csproj", "{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49}"
124-
EndProject
125121
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Certs", "Certs", "{743F8EC2-004E-4640-B04F-5BAFDA8BF112}"
126122
EndProject
127123
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InteropTests", "InteropTests", "{50CF39FF-2644-4B5F-BE1A-B57487B9723B}"
@@ -150,6 +146,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ticketer", "examples\Client
150146
EndProject
151147
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grpc.AspNetCore.Server.ClientFactory.Tests", "test\Grpc.AspNetCore.Server.ClientFactory.Tests\Grpc.AspNetCore.Server.ClientFactory.Tests.csproj", "{4306E048-9D81-44A8-8069-2C294289FC00}"
152148
EndProject
149+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grpc.Net.Client", "src\Grpc.Net.Client\Grpc.Net.Client.csproj", "{095F2B46-16DC-4A2E-A075-A0373D902294}"
150+
EndProject
151+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grpc.Net.Client.Tests", "test\Grpc.Net.Client.Tests\Grpc.Net.Client.Tests.csproj", "{7C299E2C-A5FE-439D-A346-2A676302BD04}"
152+
EndProject
153153
Global
154154
GlobalSection(SolutionConfigurationPlatforms) = preSolution
155155
Debug|Any CPU = Debug|Any CPU
@@ -208,10 +208,6 @@ Global
208208
{C3D6C3BD-4E56-4B0F-88FD-4F2D68F0CD25}.Debug|Any CPU.Build.0 = Debug|Any CPU
209209
{C3D6C3BD-4E56-4B0F-88FD-4F2D68F0CD25}.Release|Any CPU.ActiveCfg = Release|Any CPU
210210
{C3D6C3BD-4E56-4B0F-88FD-4F2D68F0CD25}.Release|Any CPU.Build.0 = Release|Any CPU
211-
{FA2EF163-D774-4A28-94D7-F0A5D1A11892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
212-
{FA2EF163-D774-4A28-94D7-F0A5D1A11892}.Debug|Any CPU.Build.0 = Debug|Any CPU
213-
{FA2EF163-D774-4A28-94D7-F0A5D1A11892}.Release|Any CPU.ActiveCfg = Release|Any CPU
214-
{FA2EF163-D774-4A28-94D7-F0A5D1A11892}.Release|Any CPU.Build.0 = Release|Any CPU
215211
{20B3B4DC-0BF1-406B-83EC-D105B6FA846A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
216212
{20B3B4DC-0BF1-406B-83EC-D105B6FA846A}.Debug|Any CPU.Build.0 = Debug|Any CPU
217213
{20B3B4DC-0BF1-406B-83EC-D105B6FA846A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -228,10 +224,6 @@ Global
228224
{291E5BA5-608D-406D-A2DB-389412D907F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
229225
{291E5BA5-608D-406D-A2DB-389412D907F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
230226
{291E5BA5-608D-406D-A2DB-389412D907F3}.Release|Any CPU.Build.0 = Release|Any CPU
231-
{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
232-
{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49}.Debug|Any CPU.Build.0 = Debug|Any CPU
233-
{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49}.Release|Any CPU.ActiveCfg = Release|Any CPU
234-
{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49}.Release|Any CPU.Build.0 = Release|Any CPU
235227
{D15CAEF6-0A5D-416E-B6F7-DE75C4B1D89B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
236228
{D15CAEF6-0A5D-416E-B6F7-DE75C4B1D89B}.Debug|Any CPU.Build.0 = Debug|Any CPU
237229
{D15CAEF6-0A5D-416E-B6F7-DE75C4B1D89B}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -248,6 +240,14 @@ Global
248240
{4306E048-9D81-44A8-8069-2C294289FC00}.Debug|Any CPU.Build.0 = Debug|Any CPU
249241
{4306E048-9D81-44A8-8069-2C294289FC00}.Release|Any CPU.ActiveCfg = Release|Any CPU
250242
{4306E048-9D81-44A8-8069-2C294289FC00}.Release|Any CPU.Build.0 = Release|Any CPU
243+
{095F2B46-16DC-4A2E-A075-A0373D902294}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
244+
{095F2B46-16DC-4A2E-A075-A0373D902294}.Debug|Any CPU.Build.0 = Debug|Any CPU
245+
{095F2B46-16DC-4A2E-A075-A0373D902294}.Release|Any CPU.ActiveCfg = Release|Any CPU
246+
{095F2B46-16DC-4A2E-A075-A0373D902294}.Release|Any CPU.Build.0 = Release|Any CPU
247+
{7C299E2C-A5FE-439D-A346-2A676302BD04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
248+
{7C299E2C-A5FE-439D-A346-2A676302BD04}.Debug|Any CPU.Build.0 = Debug|Any CPU
249+
{7C299E2C-A5FE-439D-A346-2A676302BD04}.Release|Any CPU.ActiveCfg = Release|Any CPU
250+
{7C299E2C-A5FE-439D-A346-2A676302BD04}.Release|Any CPU.Build.0 = Release|Any CPU
251251
EndGlobalSection
252252
GlobalSection(SolutionProperties) = preSolution
253253
HideSolutionNode = FALSE
@@ -275,13 +275,11 @@ Global
275275
{98500D54-FC3F-4A42-B74D-51930C19B175} = {4163E1B3-4D75-46B4-9107-9A158FD708FC}
276276
{A551D7B1-D75A-43F0-A8E3-BAEA5EDF616A} = {59C7B1F0-EE4D-4098-8596-0ADDBC305234}
277277
{C3D6C3BD-4E56-4B0F-88FD-4F2D68F0CD25} = {D4F0A67C-935C-429A-8785-22AE92FD37F6}
278-
{FA2EF163-D774-4A28-94D7-F0A5D1A11892} = {8C62055F-8CD7-4859-9001-634D544DF2AE}
279278
{20B3B4DC-0BF1-406B-83EC-D105B6FA846A} = {F6E0F9D7-64E5-4C7B-A9BC-3C2AD687710B}
280279
{39320CA8-D8F0-45B6-B704-A04C16870226} = {310E5783-455A-4D09-A7AE-39DC2AB09504}
281280
{55813F20-1269-4B19-B03E-7E4A90148F92} = {8C62055F-8CD7-4859-9001-634D544DF2AE}
282281
{86AD33E9-2C07-45BD-B599-420C2618188D} = {F6E0F9D7-64E5-4C7B-A9BC-3C2AD687710B}
283282
{291E5BA5-608D-406D-A2DB-389412D907F3} = {59C7B1F0-EE4D-4098-8596-0ADDBC305234}
284-
{2D26FB7A-72AD-41B9-9B06-44F50A8F8A49} = {CECC4AE8-9C4E-4727-939B-517CC2E58D65}
285283
{743F8EC2-004E-4640-B04F-5BAFDA8BF112} = {59C7B1F0-EE4D-4098-8596-0ADDBC305234}
286284
{50CF39FF-2644-4B5F-BE1A-B57487B9723B} = {743F8EC2-004E-4640-B04F-5BAFDA8BF112}
287285
{6DC078D2-8FB1-4685-B9BE-61F1C0ED8053} = {BF1393D4-6099-4EF9-85BB-7EE6CBEB920C}
@@ -290,6 +288,8 @@ Global
290288
{BF9F5674-2BC3-446E-BBEA-3055A4A2B889} = {8C62055F-8CD7-4859-9001-634D544DF2AE}
291289
{64CC84DE-C5A1-46B9-9A1B-8CDD730239A9} = {F6E0F9D7-64E5-4C7B-A9BC-3C2AD687710B}
292290
{4306E048-9D81-44A8-8069-2C294289FC00} = {CECC4AE8-9C4E-4727-939B-517CC2E58D65}
291+
{095F2B46-16DC-4A2E-A075-A0373D902294} = {8C62055F-8CD7-4859-9001-634D544DF2AE}
292+
{7C299E2C-A5FE-439D-A346-2A676302BD04} = {CECC4AE8-9C4E-4727-939B-517CC2E58D65}
293293
EndGlobalSection
294294
GlobalSection(ExtensibilityGlobals) = postSolution
295295
SolutionGuid = {CD5C2B19-49B4-480A-990C-36D98A719B07}

examples/Clients/Greeter/Greeter.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
<Content Include="@(Protobuf)" LinkBase="" />
1717

1818
<Compile Include="$(MSBuildThisFileDirectory)..\..\Shared\*.cs" />
19-
20-
<ProjectReference Include="..\..\..\src\Grpc.NetCore.HttpClient\Grpc.NetCore.HttpClient.csproj" />
2119
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
20+
<PackageReference Include="Grpc.Core" Version="$(GrpcPackageVersion)" />
2221
<PackageReference Include="Grpc.Tools" Version="$(GrpcPackageVersion)" PrivateAssets="All" />
2322
</ItemGroup>
2423

examples/Clients/Ticketer/Ticketer.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
<Content Include="@(Protobuf)" LinkBase="" />
1717

1818
<Compile Include="$(MSBuildThisFileDirectory)..\..\Shared\*.cs" />
19-
20-
<ProjectReference Include="..\..\..\src\Grpc.NetCore.HttpClient\Grpc.NetCore.HttpClient.csproj" />
2119
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
20+
<PackageReference Include="Grpc.Core" Version="$(GrpcPackageVersion)" />
2221
<PackageReference Include="Grpc.Tools" Version="$(GrpcPackageVersion)" PrivateAssets="All" />
2322
</ItemGroup>
2423

perf/benchmarkapps/BenchmarkClient/BenchmarkClient.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
<Compile Include="$(MSBuildThisFileDirectory)..\..\Shared\*.cs" />
1919

20+
<ProjectReference Include="..\..\..\src\Grpc.Net.Client\Grpc.Net.Client.csproj" />
21+
2022
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
2123
<PackageReference Include="Grpc.Core" Version="$(GrpcPackageVersion)" />
2224
<PackageReference Include="Grpc.Tools" Version="$(GrpcPackageVersion)" PrivateAssets="All" />
@@ -35,10 +37,6 @@
3537
</None>
3638
</ItemGroup>
3739

38-
<ItemGroup>
39-
<ProjectReference Include="..\..\..\src\Grpc.NetCore.HttpClient\Grpc.NetCore.HttpClient.csproj" />
40-
</ItemGroup>
41-
4240
<ItemGroup>
4341
<None Include="..\Shared\Certs\ca.crt" Link="Certs\ca.crt">
4442
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

perf/benchmarkapps/BenchmarkClient/Workers/GrpcHttpClientUnaryWorker.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
#endregion
1818

19+
using System;
20+
using System.Net.Http;
1921
using System.Threading.Tasks;
2022
using Greet;
21-
using Grpc.NetCore.HttpClient;
23+
using Grpc.Net.Client;
2224

2325
namespace BenchmarkClient.Workers
2426
{
@@ -43,7 +45,10 @@ public async Task CallAsync()
4345

4446
public Task ConnectAsync()
4547
{
46-
_client = GrpcClientFactory.Create<Greeter.GreeterClient>(BaseUri);
48+
_client = GrpcClient.Create<Greeter.GreeterClient>(new HttpClient
49+
{
50+
BaseAddress = new Uri(BaseUri, UriKind.RelativeOrAbsolute)
51+
});
4752
return Task.CompletedTask;
4853
}
4954

src/Grpc.AspNetCore.Server.ClientFactory/Grpc.AspNetCore.Server.ClientFactory.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1010

1111
<ProjectReference Include="..\Grpc.AspNetCore.Server\Grpc.AspNetCore.Server.csproj" />
12-
<ProjectReference Include="..\Grpc.NetCore.HttpClient\Grpc.NetCore.HttpClient.csproj" />
12+
<ProjectReference Include="..\Grpc.Net.Client\Grpc.Net.Client.csproj" />
1313
<PackageReference Include="Grpc.Core" Version="$(GrpcPackageVersion)" />
1414
</ItemGroup>
1515
</Project>

src/Grpc.AspNetCore.Server.ClientFactory/Internal/GrpcHttpClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
using System.Threading;
2222
using Grpc.AspNetCore.Server.Features;
2323
using Grpc.Core;
24-
using Grpc.NetCore.HttpClient;
24+
using Grpc.Net.Client;
2525
using Microsoft.AspNetCore.Http;
2626
using Microsoft.Extensions.DependencyInjection;
2727
using Microsoft.Extensions.Logging;
File renamed without changes.

src/Grpc.NetCore.HttpClient/GrpcClientFactory.cs renamed to src/Grpc.Net.Client/GrpcClient.cs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,26 @@
1919
using System;
2020
using System.Linq.Expressions;
2121
using System.Net.Http;
22-
using System.Security.Cryptography.X509Certificates;
2322
using System.Threading;
2423
using Grpc.Core;
2524
using Microsoft.Extensions.Logging;
2625

27-
namespace Grpc.NetCore.HttpClient
26+
namespace Grpc.Net.Client
2827
{
2928
/// <summary>
30-
/// Factory for creating gRPC clients that will use HttpClient to make gRPC calls.
29+
/// Factory for creating gRPC clients that will use <see cref="HttpClient"/> to make gRPC calls.
3130
/// </summary>
32-
public static class GrpcClientFactory
31+
public static class GrpcClient
3332
{
3433
/// <summary>
35-
/// Creates a gRPC client using the specified address.
34+
/// Creates a gRPC client using the specified <see cref="HttpClient"/>.
3635
/// </summary>
3736
/// <typeparam name="TClient">The type of the gRPC client. This type will typically be defined using generated code from a *.proto file.</typeparam>
38-
/// <param name="baseAddress">The base address to use when making gRPC requests.</param>
39-
/// <param name="certificate">The client certificate to use when making gRPC requests.</param>
37+
/// <param name="httpClient">The <see cref="HttpClient"/>.</param>
4038
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
4139
/// <returns>A gRPC client.</returns>
42-
public static TClient Create<TClient>(string baseAddress, X509Certificate? certificate = null, ILoggerFactory? loggerFactory = null) where TClient : ClientBase<TClient>
40+
public static TClient Create<TClient>(HttpClient httpClient, ILoggerFactory? loggerFactory = null) where TClient : ClientBase<TClient>
4341
{
44-
var httpClientHandler = new HttpClientHandler();
45-
httpClientHandler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true;
46-
if (certificate != null)
47-
{
48-
httpClientHandler.ClientCertificates.Add(certificate);
49-
}
50-
51-
return CreateCore<TClient>(baseAddress, httpClientHandler, loggerFactory);
52-
}
53-
54-
/// <summary>
55-
/// Creates a gRPC client using the specified address and handler.
56-
/// </summary>
57-
/// <typeparam name="TClient">The type of the gRPC client. This type will typically be defined using generated code from a *.proto file.</typeparam>
58-
/// <param name="baseAddress">The base address to use when making gRPC requests.</param>
59-
/// <param name="httpClientHandler">The <see cref="HttpClientHandler"/>.</param>
60-
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
61-
/// <returns>A gRPC client.</returns>
62-
public static TClient Create<TClient>(string baseAddress, HttpClientHandler httpClientHandler, ILoggerFactory? loggerFactory) where TClient : ClientBase<TClient>
63-
{
64-
return CreateCore<TClient>(baseAddress, httpClientHandler, loggerFactory);
65-
}
66-
67-
private static TClient CreateCore<TClient>(string baseAddress, HttpClientHandler httpClientHandler, ILoggerFactory? loggerFactory) where TClient : ClientBase<TClient>
68-
{
69-
var httpClient = new System.Net.Http.HttpClient(httpClientHandler);
70-
httpClient.BaseAddress = new Uri(baseAddress, UriKind.RelativeOrAbsolute);
71-
7242
return Cache<TClient>.Instance.Activator(new HttpClientCallInvoker(httpClient, loggerFactory));
7343
}
7444

src/Grpc.NetCore.HttpClient/HttpClientCallInvoker.cs renamed to src/Grpc.Net.Client/HttpClientCallInvoker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
using System;
2020
using System.Threading;
2121
using Grpc.Core;
22-
using Grpc.NetCore.HttpClient.Internal;
22+
using Grpc.Net.Client.Internal;
2323
using Microsoft.Extensions.Logging;
2424
using Microsoft.Extensions.Logging.Abstractions;
2525

26-
namespace Grpc.NetCore.HttpClient
26+
namespace Grpc.Net.Client
2727
{
2828
/// <summary>
2929
/// A client-side RPC invocation using HttpClient.

0 commit comments

Comments
 (0)