Gnat-Grpc
对 grpc 的封装,简化 unary calls,目前尚不支持 streaming calls。
Installation
npm install grpc gnat-grpc
Usage
helloworld.proto: 使用官方示例中的 helloworld.proto
public-conf.js:
const gnatGrpc = ;const grpc = ;const protoLoader = ; // 仅能调用一次gnatGrpc;
server.js:
;const Server = ; const sayHello = async { return message: 'Hello ' + argsname;}; async { const PORT = 50051; const server = bindPath: `0.0.0.0:` ; await server; serverstart;};
client.js:
;const Client = ; async { const PORT = 50051; const service = await client; const ret = await service; console; // {message: 'Hello World'}};
To Do
// 支持 client retry