gRPC Reflection
gRPCity 服务端实现了 gRPC Server Reflection Protocol,Postman、grpcurl 这类工具可以直接在 wire 上探测你的服务,不需要本地的 .proto 文件副本。
用法
从 loader 构造反射服务并注入到 server:
const server = await loader.initServer()
const reflection = await loader.initReflection()
server.inject(reflection)Unary Call
我们使用 gRPCity 里的 example/reflection/helloworldServer.js 作为 Unary Call 例子。
Terminal
node example/reflection/helloworldServer.js
start: localhost:9098服务启动后就可以使用postman进行接入测试,演示如下:
Async Stream
我们使用 gRPCity 里的 example/reflection/asyncStreamServer.js 作为 Async Stream 例子。
Terminal
node example/reflection/asyncStreamServer.js
start: localhost:9097服务启动后就可以使用postman进行接入测试,演示如下:
Client Stream
Server Stream
Bidi Stream
Last updated on