www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - hunt-grpc 0.1.1 released! (Google gRPC for D)

reply Brian <zoujiaqing gmail.com> writes:
Google gRPC is A high performance, open-source universal RPC 
framework.

You can find it here:
https://grpc.io/

hunt-grpc is a GRPC framework developed in D language. The new 
version mainly supports two-way communication and fixes some 
known errors.

Example for server:
```D
   import helloworld.helloworld;
   import helloworld.helloworldrpc;
   import grpc;

   class GreeterImpl : GreeterBase
   {
       override Status SayHello(HelloRequest request , ref 
HelloReply reply)
       {
           reply.message = "hello " ~ request.name;
           return Status.OK;
       }
   }

   string host = "0.0.0.0";
   ushort port = 50051;

   Server server = new Server();
   server.listen(host , port);
   server.register( new GreeterImpl());
   server.start();
```

Example for client:
```D
   import helloworld.helloworld;
   import helloworld.helloworldrpc;
   import grpc;
   import std.stdio;

   auto channel = new Channel("127.0.0.1" , 50051);
   GreeterClient client = new GreeterClient(channel);

   HelloRequest request = new HelloRequest();
   HelloReply reply = new HelloReply();
   request.name = "test";
   auto status = client.SayHello(request , reply);
   if(status.ok())
   {
      writeln(reply.message);
   }
```

Example for streaming:

We implemented the offical example RouteGuide

offical 
link:https://github.com/grpc/grpc/blob/master/examples/cpp/cpptutorial.md


More support in hunt-grpc github repo:
https://github.com/huntlabs/hunt-grpc
Jan 16 2019
parent reply viniarck <viniarck gmail.com> writes:
On Thursday, 17 January 2019 at 04:19:27 UTC, Brian wrote:
 Google gRPC is A high performance, open-source universal RPC 
 framework.

 [...]
Cool. Thanks for contributing. I look forward to using it in a future project with microservices.
Jan 24 2019
parent Brian <zoujiaqing gmail.com> writes:
On Thursday, 24 January 2019 at 21:17:24 UTC, viniarck wrote:
 On Thursday, 17 January 2019 at 04:19:27 UTC, Brian wrote:
 Google gRPC is A high performance, open-source universal RPC 
 framework.

 [...]
Cool. Thanks for contributing. I look forward to using it in a future project with microservices.
Yes, we use it for a lot of projects :)
Jan 25 2019