hunt-grpc 0.1.1 released! (Google gRPC for D)
Brian
zoujiaqing at gmail.com
Thu Jan 17 04:19:27 UTC 2019
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
More information about the Digitalmars-d-announce
mailing list