GRPC中间件库是否支持grpc-node?我对记录grpc proto请求很感兴趣,似乎我必须学习golang才能有一个记录功能?
发布于 2020-08-06 01:40:10
当然,你不需要为此学习Golang。您只需要检查如何在node中使用gRPC拦截器。在拦截器代码中,您将实现Golang的gRPC中间件中提供的任何特性。
应该是这样的。
const interceptors = require('grpc-interceptors');
const server = interceptors.serverProxy(new grpc.Server());
server.addService(proto.MyPackage.MyService.service, { Method1, Method2 });
const myMiddlewareFunc = function (ctx, next) {
// do stuff before call
console.log('Making gRPC call...');
await next()
// do stuff after call
console.log(ctx.status.code);
}
server.use(myMiddlewareFunc);https://stackoverflow.com/questions/62905862
复制相似问题