Add a gRPC client
This commit is contained in:
parent
ab7a34ceb2
commit
a0df169e85
13
Tasks/Lab11/RankingService/RankingClient/Program.cs
Normal file
13
Tasks/Lab11/RankingService/RankingClient/Program.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using Grpc.Net.Client;
|
||||||
|
using RankingService;
|
||||||
|
using static RankingService.Ranking;
|
||||||
|
|
||||||
|
GrpcChannel channel = GrpcChannel.ForAddress("http://localhost:8000");
|
||||||
|
RankingClient client = new RankingClient(channel);
|
||||||
|
var result = await client.GetRankingAsync(new RankingService.RankingRequest());
|
||||||
|
|
||||||
|
for (int i = 0; i < result.Competitors.Count; i++)
|
||||||
|
{
|
||||||
|
Competitor competitor = result.Competitors[i];
|
||||||
|
Console.WriteLine($"{i + 1}. {competitor.Name}, {competitor.Time}");
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Google.Protobuf" Version="3.21.5" />
|
||||||
|
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.49.0" />
|
||||||
|
<PackageReference Include="Grpc.Tools" Version="2.49.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Protobuf Include="..\RankingService\Protos\ranking.proto" GrpcServices="Client">
|
||||||
|
<Link>Protos\ranking.proto</Link>
|
||||||
|
</Protobuf>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -5,6 +5,8 @@ VisualStudioVersion = 17.10.34928.147
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RankingService", "RankingService\RankingService.csproj", "{DE7F9795-772A-4134-895F-3F65193E86BE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RankingService", "RankingService\RankingService.csproj", "{DE7F9795-772A-4134-895F-3F65193E86BE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RankingClient", "RankingClient\RankingClient.csproj", "{9373A533-CDFC-4EEC-AE5A-9CE87F099697}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -15,6 +17,10 @@ Global
|
||||||
{DE7F9795-772A-4134-895F-3F65193E86BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DE7F9795-772A-4134-895F-3F65193E86BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DE7F9795-772A-4134-895F-3F65193E86BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DE7F9795-772A-4134-895F-3F65193E86BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DE7F9795-772A-4134-895F-3F65193E86BE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DE7F9795-772A-4134-895F-3F65193E86BE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9373A533-CDFC-4EEC-AE5A-9CE87F099697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9373A533-CDFC-4EEC-AE5A-9CE87F099697}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9373A533-CDFC-4EEC-AE5A-9CE87F099697}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9373A533-CDFC-4EEC-AE5A-9CE87F099697}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in a new issue