Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

4 changes: 4 additions & 0 deletions investigations/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Visual Studio - C#
**/obj
**/bin
*.user
25 changes: 25 additions & 0 deletions investigations/DotNetGrpc/DotNetGrpc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetGrpcService", "DotNetGrpcService\DotNetGrpcService.csproj", "{51C71ABB-1D35-4543-898C-0D34EFF832FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{51C71ABB-1D35-4543-898C-0D34EFF832FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51C71ABB-1D35-4543-898C-0D34EFF832FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51C71ABB-1D35-4543-898C-0D34EFF832FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51C71ABB-1D35-4543-898C-0D34EFF832FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB4EB881-58FA-4A49-838A-0F0824C47920}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.10.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.23.2" />
Expand All @@ -16,4 +16,5 @@
<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Client" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using DotNetGrpcService;
using Grpc.Net.Client;

namespace GrpcGreeterClient
namespace DotNetGrpcClient
{
class Program
class Program
{
static async Task Main(string[] args)
{
Expand All @@ -18,9 +18,6 @@ static async Task Main(string[] args)
Console.WriteLine("Calling Python Endpoint...");
await CallEndpoint("http://localhost:50051", true);


Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}

static GrpcChannel GetChannel(string grpcEndpointAddress, bool isInsecure = false)
Expand All @@ -35,8 +32,8 @@ static async Task CallEndpoint(string grpcEndpointAddress, bool isInsecure = fal
var client = new Greeter.GreeterClient(channel);

var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
new HelloRequest { Name = "GreeterClient-DotNet" });
Console.WriteLine($"Response: {reply.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ message HelloRequest {
// The response message containing the greetings.
message HelloReply {
string message = 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.23.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContex
{
return Task.FromResult(new HelloReply
{
Message = "Hello " + request.Name
Message = $"Hello {request.Name} from .NET gRPC Server"
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseEndpoints(endpoints =>
{

endpoints.MapGrpcService<GreeterService>();

endpoints.MapGet("/", async context =>
Expand Down
21 changes: 0 additions & 21 deletions investigations/DotNetGrpcService/DotNetGrpcService.csproj

This file was deleted.

31 changes: 0 additions & 31 deletions investigations/DotNetGrpcService/DotNetGrpcService.sln

This file was deleted.

20 changes: 11 additions & 9 deletions investigations/PythonGrpc/greet_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
import greet_pb2



def getChannel(grpcEndpointAddress):
return grpc.insecure_channel(grpcEndpointAddress)


def sendGreetings(grpcChannel):
stub = greet_pb2_grpc.GreeterStub(grpcChannel)
reply = stub.SayHello(greet_pb2.HelloRequest(name='Shashank'))
return reply
reply = stub.SayHello(greet_pb2.HelloRequest(name='GreeterClient-Python'))
return reply.message

def main():
print ("Send greetings to C# Server...")

def main():
print("Calling C# Endpoint...")
channel = getChannel("localhost:5000")
print(sendGreetings(channel))
print(f'Response: {sendGreetings(channel)}')

print ("Send greetings to Python Server...")
print("Calling Python Endpoint...")
channel = getChannel("localhost:50051")
print(sendGreetings(channel))
print(f'Response: {sendGreetings(channel)}')


if __name__ == '__main__':
if __name__ == '__main__':
main()
12 changes: 7 additions & 5 deletions investigations/PythonGrpc/greet_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import greet_pb2_grpc
import greet_pb2


class GreetServer (greet_pb2_grpc.GreeterServicer):

def SayHello(self, request, context):
print(f'Received client request from {request.name}')
return greet_pb2.HelloReply(message='Hello ' + request.name)

return greet_pb2.HelloReply(message=f'Hello {request.name} from Python gRPC Server')


def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
greet_pb2_grpc.add_GreeterServicer_to_server(GreetServer(), server)
Expand All @@ -20,5 +22,5 @@ def serve():
server.wait_for_termination()


if __name__ == '__main__':
serve()
if __name__ == '__main__':
serve()
2 changes: 2 additions & 0 deletions investigations/PythonGrpc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flake8
grpcio-tools
Loading