grpc 0.2.0

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


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

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.5.0-beta.2 2022-Mar-06
0.5.0-beta.1 2021-Oct-29
0.4.0-beta.1 2021-Jan-27
0.3.0-beta.5 2020-Oct-28
0.3.0-beta.4 2020-Oct-02
Show all 7 versions
Download Stats:
  • 2 downloads today

  • 9 downloads this week

  • 41 downloads this month

  • 1184 downloads total

Score:
2.2
Short URL:
grpc.dub.pm