grpc 0.2.0

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

Build Status

DLang 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=./examples -I ./examples ./examples/helloworld.proto

Generating grpc client and server code

git submodule update --init --recursive
cd compiler
mkdir build
cd build
cmake ..
make -j4

protoc -I ./examples --grpcout=./examples --plugin=protoc-gen-grpc=grpcdlang_plugin ./examples/helloworld.proto

# example-server

  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-client

  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();
  request.name = "test";
  HelloReply reply = client.SayHello(request);
  if(reply !is null)
  {
     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

# build (dmd only , some bug in ldc)

for library:

dub build

for example:

 dub build -c=example
 ./example

for streaming example:

 dub build -c=streamexample
 ./streamexample -f ./examples/route_guide_db.json
Dependencies:
protobuf, hunt-http
Versions:
0.2.0 2019-Mar-12
~master 2019-Mar-21
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 11 downloads this week

  • 15 downloads this month

  • 24 downloads total

Score:
1.8
Short URL:
grpc.dub.pm