Browse Source

first approach

features/migration-dotnet3
ericuss 5 years ago
parent
commit
e58429ac2a
12 changed files with 284 additions and 137 deletions
  1. +1
    -0
      docker-compose.override.yml
  2. +56
    -51
      eShopOnContainers.sln
  3. +16
    -0
      src/Clients/Clients.Grpc.Caller/Clients.Grpc.Caller.csproj
  4. +37
    -0
      src/Clients/Clients.Grpc.Caller/Program.cs
  5. +34
    -0
      src/Clients/Clients.Grpc.Caller/Protos/basket.proto
  6. +3
    -3
      src/Services/Basket/Basket.API/Basket.API.csproj
  7. +57
    -32
      src/Services/Basket/Basket.API/Grpc/BasketService.cs
  8. +1
    -1
      src/Services/Basket/Basket.API/Program.cs
  9. +2
    -8
      src/Services/Basket/Basket.API/Proto/basket.proto
  10. +64
    -39
      src/Services/Basket/Basket.API/Startup.cs
  11. +10
    -0
      src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs
  12. +3
    -3
      src/_build/dependencies.props

+ 1
- 0
docker-compose.override.yml View File

@ -72,6 +72,7 @@ services:
ports: ports:
- "5103:80" - "5103:80"
- "5580:5001"
catalog.api: catalog.api:
environment: environment:


+ 56
- 51
eShopOnContainers.sln View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2024
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.88
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
EndProject EndProject
@ -163,6 +163,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devspaces.Support", "Devspa
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{CB6D01A4-E597-4348-9570-FC8DB03B4267}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{CB6D01A4-E597-4348-9570-FC8DB03B4267}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{8449B293-5949-4832-8612-6BCE2962BCB1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Clients.Grpc.Caller", "src\Clients\Clients.Grpc.Caller\Clients.Grpc.Caller.csproj", "{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -1369,54 +1373,6 @@ Global
{A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.ActiveCfg = Release|x86 {A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.ActiveCfg = Release|x86
{A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.Build.0 = Release|x86 {A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.Build.0 = Release|x86
{A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.Deploy.0 = Release|x86 {A7337243-33B8-463A-87AD-944B75EFD820}.Release|x86.Deploy.0 = Release|x86
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|ARM.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|iPhone.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|x64.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|x64.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|x86.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.AppStore|x86.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|ARM.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|ARM.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|iPhone.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|x64.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|x64.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|x86.ActiveCfg = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Debug|x86.Build.0 = Debug|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|Any CPU.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|ARM.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|ARM.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|iPhone.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|iPhone.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x64.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x64.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.Build.0 = Release|Any CPU
{9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU {9F00E62F-E180-4A9C-8794-98A72AFAC2DB}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
@ -2089,6 +2045,54 @@ Global
{CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x64.Build.0 = Release|Any CPU {CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x64.Build.0 = Release|Any CPU
{CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x86.ActiveCfg = Release|Any CPU {CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x86.ActiveCfg = Release|Any CPU
{CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x86.Build.0 = Release|Any CPU {CB6D01A4-E597-4348-9570-FC8DB03B4267}.Release|x86.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|ARM.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|iPhone.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|x64.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|x64.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|x86.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.AppStore|x86.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|ARM.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|iPhone.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|x64.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Debug|x86.Build.0 = Debug|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|Any CPU.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|ARM.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|ARM.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|iPhone.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|iPhone.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|x64.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|x64.Build.0 = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|x86.ActiveCfg = Release|Any CPU
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -2136,7 +2140,6 @@ Global
{A289A7F0-ACD8-42AE-87B6-AB1AFD310BF1} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90} {A289A7F0-ACD8-42AE-87B6-AB1AFD310BF1} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90}
{B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90} {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90}
{A7337243-33B8-463A-87AD-944B75EFD820} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90} {A7337243-33B8-463A-87AD-944B75EFD820} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90}
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
{9F00E62F-E180-4A9C-8794-98A72AFAC2DB} = {7BA332A2-189D-4D03-9935-FDFF81C42496} {9F00E62F-E180-4A9C-8794-98A72AFAC2DB} = {7BA332A2-189D-4D03-9935-FDFF81C42496}
{63417272-1E6A-406A-AD11-C738558D89C0} = {7BA332A2-189D-4D03-9935-FDFF81C42496} {63417272-1E6A-406A-AD11-C738558D89C0} = {7BA332A2-189D-4D03-9935-FDFF81C42496}
{56E0E455-731E-41CB-AF46-C1A70F8A140B} = {2F0DEF71-84AC-4212-86D4-E36E8896BDBF} {56E0E455-731E-41CB-AF46-C1A70F8A140B} = {2F0DEF71-84AC-4212-86D4-E36E8896BDBF}
@ -2163,6 +2166,8 @@ Global
{E39BD762-BC86-459D-B818-B6BF2D9F1352} = {424BC53E-17EA-4E12-BC07-64BAA927ABCB} {E39BD762-BC86-459D-B818-B6BF2D9F1352} = {424BC53E-17EA-4E12-BC07-64BAA927ABCB}
{ABBA561B-499B-48C0-8299-85D41E6E9E98} = {DB0EFB20-B024-4E5E-A75C-52143C131D25} {ABBA561B-499B-48C0-8299-85D41E6E9E98} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{CB6D01A4-E597-4348-9570-FC8DB03B4267} = {ABBA561B-499B-48C0-8299-85D41E6E9E98} {CB6D01A4-E597-4348-9570-FC8DB03B4267} = {ABBA561B-499B-48C0-8299-85D41E6E9E98}
{8449B293-5949-4832-8612-6BCE2962BCB1} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{7C8FA264-ED49-4ACA-9629-FCE5462B30AB} = {8449B293-5949-4832-8612-6BCE2962BCB1}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9}


+ 16
- 0
src/Clients/Clients.Grpc.Caller/Clients.Grpc.Caller.csproj View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.9.1" />
<PackageReference Include="Grpc.Net.Client" Version="0.1.22-pre3" />
<PackageReference Include="Grpc.Tools" Version="2.23.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\basket.proto" GrpcServices="Client" />
</ItemGroup>
</Project>

+ 37
- 0
src/Clients/Clients.Grpc.Caller/Program.cs View File

@ -0,0 +1,37 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Grpc.Net.Client;
using GrpcBasket;
namespace Clients.Grpc.Caller
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Starting...");
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using (var httpClientHandler = new HttpClientHandler())
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
// Make your request...
// var httpClient = new HttpClient();
// The port number(5001) must match the port of the gRPC server.
//httpClient.BaseAddress = new Uri("http://localhost:5103");
httpClient.BaseAddress = new Uri("http://localhost:5580");
//httpClient.DefaultRequestVersion = Version.Parse("2.0");
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
var reply = await client.GetBasketByIdAsync(
new BasketRequest { Id = "11" });
Console.WriteLine("Greeting: " + reply.Buyerid);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
}
}

+ 34
- 0
src/Clients/Clients.Grpc.Caller/Protos/basket.proto View File

@ -0,0 +1,34 @@
syntax = "proto3";
option csharp_namespace = "GrpcBasket";
package BasketApi;
service Basket {
rpc GetBasketById(BasketRequest) returns (CustomerBasketResponse);
rpc UpdateBasket(CustomerBasketRequest) returns (CustomerBasketResponse);
}
message BasketRequest {
string id = 1;
}
message CustomerBasketRequest {
string buyerid = 1;
repeated BasketItemResponse items = 2;
}
message CustomerBasketResponse {
string buyerid = 1;
repeated BasketItemResponse items = 2;
}
message BasketItemResponse {
string id = 1;
string productid = 2;
string productname = 3;
double unitprice = 4;
double oldunitprice = 5;
int32 quantity = 6;
string pictureurl = 7;
}

+ 3
- 3
src/Services/Basket/Basket.API/Basket.API.csproj View File

@ -27,11 +27,11 @@
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="$(Microsoft_ApplicationInsights_AspNetCore)" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="$(Microsoft_ApplicationInsights_AspNetCore)" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="$(Microsoft_ApplicationInsights_DependencyCollector)" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="$(Microsoft_ApplicationInsights_DependencyCollector)" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="$(Microsoft_ApplicationInsights_Kubernetes)" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="$(Microsoft_ApplicationInsights_Kubernetes)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(Microsoft_AspNetCore_Authentication_JwtBearer)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0-preview8.19405.7" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="$(Microsoft_AspNetCore_Diagnostics_HealthChecks)" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="$(Microsoft_AspNetCore_Diagnostics_HealthChecks)" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="$(Microsoft_AspNetCore_HealthChecks)" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="$(Microsoft_AspNetCore_HealthChecks)" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="$(Microsoft_Extensions_Configuration_AzureKeyVault)" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="$(Microsoft_Extensions_Logging_AzureAppServices)" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.0.0-preview8.19405.4" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.0.0-preview8.19405.4" />
<PackageReference Include="Serilog.AspNetCore" Version="$(Serilog_AspNetCore)" /> <PackageReference Include="Serilog.AspNetCore" Version="$(Serilog_AspNetCore)" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="$(Serilog_Enrichers_Environment)" /> <PackageReference Include="Serilog.Enrichers.Environment" Version="$(Serilog_Enrichers_Environment)" />
<PackageReference Include="Serilog.Settings.Configuration" Version="$(Serilog_Settings_Configuration)" /> <PackageReference Include="Serilog.Settings.Configuration" Version="$(Serilog_Settings_Configuration)" />


+ 57
- 32
src/Services/Basket/Basket.API/Grpc/BasketService.cs View File

@ -1,10 +1,12 @@
using Grpc.Core; using Grpc.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Basket.API.Model;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using GrpcBasket;
namespace grpc
namespace GrpcBasket
{ {
public class BasketService : Basket.BasketBase public class BasketService : Basket.BasketBase
{ {
@ -17,24 +19,47 @@ namespace grpc
_logger = logger; _logger = logger;
} }
public override async Task<CustomerBasketResponse> GetBasketById(BasketRequest request, ServerCallContext context)
[AllowAnonymous]
public override Task<CustomerBasketResponse> GetBasketById(BasketRequest request, ServerCallContext context)
{ {
_logger.LogInformation($"Begin grpc call from method {context.Method} for basket id {request.Id}"); _logger.LogInformation($"Begin grpc call from method {context.Method} for basket id {request.Id}");
var data = await _repository.GetBasketAsync(request.Id);
//context.ResponseTrailers.Add("grpc-status", "0");
//context.Status = Status.DefaultSuccess;
if (data != null)
return Task.FromResult(new CustomerBasketResponse
{ {
context.Status = new Status(StatusCode.OK, $"Basket with id {request.Id} do exist");
Buyerid = "55"
});
return MapToCustomerBasketResponse(data);
}
else
{
context.Status = new Status(StatusCode.NotFound, $"Basket with id {request.Id} do not exist");
}
return null;
// if (!context.Response.SupportsTrailers())
// {
// var headers = new HeaderDictionary();
// headers.Add("grpc-status", "0");
// Log.Logger.Information("Custom middleware headers {@headers}", headers);
// context.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
// {
// Trailers = headers
// });
// }
// return next();
// var data = await _repository.GetBasketAsync(request.Id);
// if (data != null)
// {
// context.Status = new Status(StatusCode.OK, $"Basket with id {request.Id} do exist");
// return MapToCustomerBasketResponse(data);
// }
// else
// {
// context.Status = new Status(StatusCode.NotFound, $"Basket with id {request.Id} do not exist");
// }
// return new CustomerBasketResponse();
} }
public override async Task<CustomerBasketResponse> UpdateBasket(CustomerBasketRequest request, ServerCallContext context) public override async Task<CustomerBasketResponse> UpdateBasket(CustomerBasketRequest request, ServerCallContext context)
@ -62,16 +87,16 @@ namespace grpc
Buyerid = customerBasket.BuyerId Buyerid = customerBasket.BuyerId
}; };
customerBasket.Items.ForEach(item => response.Items.Add(new BasketItemResponse
{
Id = item.Id,
Oldunitprice = (double)item.OldUnitPrice,
Pictureurl = item.PictureUrl,
Productid = item.ProductId,
Productname = item.ProductName,
Quantity = item.Quantity,
Unitprice = (double)item.UnitPrice
}));
// customerBasket.Items.ForEach(item => response.Items.Add(new BasketItemResponse
// {
// Id = item.Id,
// Oldunitprice = (double)item.OldUnitPrice,
// Pictureurl = item.PictureUrl,
// Productid = item.ProductId,
// Productname = item.ProductName,
// Quantity = item.Quantity,
// Unitprice = (double)item.UnitPrice
// }));
return response; return response;
} }
@ -83,16 +108,16 @@ namespace grpc
BuyerId = customerBasketRequest.Buyerid BuyerId = customerBasketRequest.Buyerid
}; };
customerBasketRequest.Items.ToList().ForEach(item => response.Items.Add(new BasketItem
{
Id = item.Id,
OldUnitPrice = (decimal)item.Oldunitprice,
PictureUrl = item.Pictureurl,
ProductId = item.Productid,
ProductName = item.Productname,
Quantity = item.Quantity,
UnitPrice = (decimal)item.Unitprice
}));
// customerBasketRequest.Items.ToList().ForEach(item => response.Items.Add(new BasketItem
// {
// Id = item.Id,
// OldUnitPrice = (decimal)item.Oldunitprice,
// PictureUrl = item.Pictureurl,
// ProductId = item.Productid,
// ProductName = item.Productname,
// Quantity = item.Quantity,
// UnitPrice = (decimal)item.Unitprice
// }));
return response; return response;
} }


+ 1
- 1
src/Services/Basket/Basket.API/Program.cs View File

@ -49,7 +49,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
.ConfigureKestrel(options => .ConfigureKestrel(options =>
{ {
var ports = GetDefinedPorts(configuration); var ports = GetDefinedPorts(configuration);
options.Listen(IPAddress.Any, ports.httpPort, listenOptions => options.Listen(IPAddress.Any, ports.httpPort, listenOptions =>
{ {
listenOptions.Protocols = HttpProtocols.Http1AndHttp2; listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
@ -59,6 +58,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
{ {
listenOptions.Protocols = HttpProtocols.Http2; listenOptions.Protocols = HttpProtocols.Http2;
}); });
}) })
.UseFailing(options => options.ConfigPath = "/Failing") .UseFailing(options => options.ConfigPath = "/Failing")
.UseStartup<Startup>() .UseStartup<Startup>()


+ 2
- 8
src/Services/Basket/Basket.API/Proto/basket.proto View File

@ -1,15 +1,11 @@
syntax = "proto3"; syntax = "proto3";
option csharp_namespace = "grpc";
option csharp_namespace = "GrpcBasket";
package BasketApi; package BasketApi;
service Basket { service Basket {
rpc GetBasketById(BasketRequest) returns (CustomerBasketResponse) {
option (google.api.http) = {
get: "/GetBasketById"
};
}
rpc GetBasketById(BasketRequest) returns (CustomerBasketResponse) {}
rpc UpdateBasket(CustomerBasketRequest) returns (CustomerBasketResponse) {} rpc UpdateBasket(CustomerBasketRequest) returns (CustomerBasketResponse) {}
} }
@ -19,12 +15,10 @@ message BasketRequest {
message CustomerBasketRequest { message CustomerBasketRequest {
string buyerid = 1; string buyerid = 1;
repeated BasketItemResponse items = 2;
} }
message CustomerBasketResponse { message CustomerBasketResponse {
string buyerid = 1; string buyerid = 1;
repeated BasketItemResponse items = 2;
} }
message BasketItemResponse { message BasketItemResponse {


+ 64
- 39
src/Services/Basket/Basket.API/Startup.cs View File

@ -4,7 +4,6 @@ using Basket.API.Infrastructure.Filters;
using Basket.API.Infrastructure.Middlewares; using Basket.API.Infrastructure.Middlewares;
using Basket.API.IntegrationEvents.EventHandling; using Basket.API.IntegrationEvents.EventHandling;
using Basket.API.IntegrationEvents.Events; using Basket.API.IntegrationEvents.Events;
using grpc;
using HealthChecks.UI.Client; using HealthChecks.UI.Client;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
@ -34,6 +33,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.IO; using System.IO;
using GrpcBasket;
using Microsoft.AspNetCore.Http.Features;
using Serilog;
namespace Microsoft.eShopOnContainers.Services.Basket.API namespace Microsoft.eShopOnContainers.Services.Basket.API
{ {
@ -198,39 +200,62 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
app.UseSwagger()
.UseSwaggerUI(setup =>
{
setup.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Basket.API V1");
setup.OAuthClientId("basketswaggerui");
setup.OAuthAppName("Basket Swagger UI");
});
//app.Use((context, next) =>
//{
// Log.Logger.Information("Custom middleware to avoid trailers");
// Log.Logger.Information("Custom middleware context.Response {@context.Response}", context.Response);
// Log.Logger.Information("Custom middleware context.Response.SupportsTrailers {context.Response.SupportsTrailers}", context.Response.SupportsTrailers());
// if (!context.Response.SupportsTrailers())
// {
// var headers = new HeaderDictionary();
// headers.Add("grpc-status", "0");
// Log.Logger.Information("Custom middleware headers {@headers}", headers);
// context.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
// {
// Trailers = headers
// });
// }
// return next();
//});
//app.UseSwagger()
// .UseSwaggerUI(setup =>
// {
// setup.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Basket.API V1");
// setup.OAuthClientId("basketswaggerui");
// setup.OAuthAppName("Basket Swagger UI");
// });
app.UseRouting(); app.UseRouting();
ConfigureAuth(app);
// ConfigureAuth(app);
app.UseStaticFiles();
// app.UseStaticFiles();
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapGrpcService<BasketService>();
endpoints.MapDefaultControllerRoute(); endpoints.MapDefaultControllerRoute();
endpoints.MapControllers(); endpoints.MapControllers();
endpoints.MapGet("/_proto/", async ctx =>
{
ctx.Response.ContentType = "text/plain";
using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "basket.proto"), FileMode.Open, FileAccess.Read);
using var sr = new StreamReader(fs);
while (!sr.EndOfStream)
{
var line = await sr.ReadLineAsync();
if (line != "/* >>" || line != "<< */")
{
await ctx.Response.WriteAsync(line);
}
}
});
endpoints.MapGrpcService<BasketService>();
// endpoints.MapGet("/_proto/", async ctx =>
// {
// ctx.Response.ContentType = "text/plain";
// using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "basket.proto"), FileMode.Open, FileAccess.Read);
// using var sr = new StreamReader(fs);
// while (!sr.EndOfStream)
// {
// var line = await sr.ReadLineAsync();
// if (line != "/* >>" || line != "<< */")
// {
// await ctx.Response.WriteAsync(line);
// }
// }
// });
endpoints.MapHealthChecks("/hc", new HealthCheckOptions() endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
{ {
Predicate = _ => true, Predicate = _ => true,
@ -254,21 +279,21 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
private void ConfigureAuthService(IServiceCollection services) private void ConfigureAuthService(IServiceCollection services)
{ {
// prevent from mapping "sub" claim to nameidentifier. // prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
// JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
// var identityUrl = Configuration.GetValue<string>("IdentityUrl");
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
// services.AddAuthentication(options =>
// {
// options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
// options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.Authority = identityUrl;
options.RequireHttpsMetadata = false;
options.Audience = "basket";
});
// }).AddJwtBearer(options =>
// {
// options.Authority = identityUrl;
// options.RequireHttpsMetadata = false;
// options.Audience = "basket";
// });
} }
protected virtual void ConfigureAuth(IApplicationBuilder app) protected virtual void ConfigureAuth(IApplicationBuilder app)
@ -278,8 +303,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
app.UseMiddleware<ByPassAuthMiddleware>(); app.UseMiddleware<ByPassAuthMiddleware>();
} }
app.UseAuthentication();
app.UseAuthorization();
// app.UseAuthentication();
// app.UseAuthorization();
} }
private void RegisterEventBus(IServiceCollection services) private void RegisterEventBus(IServiceCollection services)


+ 10
- 0
src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs View File

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.eShopOnContainers.Services.Basket.API
{
internal class TestHttpResponseTrailersFeature : IHttpResponseTrailersFeature
{
public IHeaderDictionary Trailers { get; set; }
}
}

+ 3
- 3
src/_build/dependencies.props View File

@ -16,9 +16,9 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Package Versions"> <PropertyGroup Label="Package Versions">
<Grpc_AspNetCore_Server>0.1.22-pre1</Grpc_AspNetCore_Server>
<Google_Protobuf>3.9.0-rc1</Google_Protobuf>
<Grpc_Tools>1.22.0</Grpc_Tools>
<Grpc_AspNetCore_Server>0.1.22-pre3</Grpc_AspNetCore_Server>
<Google_Protobuf>3.9.1</Google_Protobuf>
<Grpc_Tools>2.23.0</Grpc_Tools>
<Grpc_AspNetCore_Server_ClientFactory>0.1.22-pre2</Grpc_AspNetCore_Server_ClientFactory> <Grpc_AspNetCore_Server_ClientFactory>0.1.22-pre2</Grpc_AspNetCore_Server_ClientFactory>
<Microsoft_Extensions_Hosting>3.0.0-preview7.19362.4</Microsoft_Extensions_Hosting> <Microsoft_Extensions_Hosting>3.0.0-preview7.19362.4</Microsoft_Extensions_Hosting>


Loading…
Cancel
Save