hunt-grpc is Grpc for D programming language, hunt-http library based.




example server code:

  import helloworld.helloworld;
  import helloworld.helloworldrpc;
  import grpc;

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

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

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





example client code:

  import helloworld.helloworld;
  import helloworld.helloworldrpc;
  import grpc;

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

  HelloRequest request = new HelloRequest();
  request.name = "test";
  HelloReply reply = client.SayHello(request);





build for library:

dub build -v





build for example:

dub build -c=example -v




hunt-grpc project:
https://github.com/huntlabs/hunt-grpc

Reply via email to