gRPC for D is released.
Brian
zoujiaqing at gmail.com
Thu Oct 11 12:15:43 UTC 2018
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
More information about the Digitalmars-d-announce
mailing list