gpt4 book ai didi

c++ - 跟踪C++ gRPC服务器中的所有RPC调用

转载 作者:行者123 更新时间:2023-12-01 15:00:56 29 4
gpt4 key购买 nike

我有一台用C++编写的gRPC服务器,如果可能的话,我想跟踪或记录对服务器的所有RPC调用,包括参数和响应。

Go gRPC实现具有非常有用的拦截器概念,可以将其附加到客户端或服务器。拦截器不仅可以访问元数据,还可以访问参数/响应。对于C++ API,我找不到任何类似的东西。

最佳答案

https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor.html呢?

我可以找到的唯一用法引用是以下SO问题:C++ grpc::experimental:interceptor how to return status and message from custom interceptor

编辑:事实上,我认为这是更好的资源-https://github.com/grpc/grpc/blob/7bf82de9eda0aa8fecfe5edb33834f1b272be30b/test/cpp/end2end/server_interceptors_end2end_test.cc

我认为您可以从拦截器重写方法methodsIntercept(grpc::experimental::InterceptorBatchMethods* methods)参数查询请求和响应消息,在此处查看可用的方法和属性:https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor_batch_methods.html

关于c++ - 跟踪C++ gRPC服务器中的所有RPC调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42345694/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com