hunt-grpc 0.0.1

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


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

hunt-grpc

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

Generating protobuf code

https://github.com/dcarp/protobuf-d

protoc --plugin=protoc-gen-d --d_out=./example -I ./doc ./doc/helloworld.proto

Generating grpc client and server code

https://github.com/huntlabs/google-grpc

protoc -I ./doc/ --grpcout=./example --plugin=protoc-gen-grpc=grpcdlang_plugin ./doc/protos/helloworld.proto

# example-server

  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

  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

for example:

 dub build -c=example
Dependencies:
hunt-http, protobuf
Versions:
0.0.1 2018-Nov-13
~master 2018-Nov-13
~add-license-1 2018-Nov-05
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.9
Short URL:
hunt-grpc.dub.pm