如何通过grpc ruby客户端添加元数据?
How to add metadata through grpc ruby client?
如何通过grpc ruby客户端添加元数据?示例代码片段会有所帮助。
元数据是任何方法调用的可选参数。例如:
metadata = { 'key' : 'value' }
response = service.method(argument, metadata: metadata)
您需要将元数据作为带有键 metadata
的哈希值传递。
在服务器端,假设您有 your_method(your_req, _call)
,元数据将以 _call.metadata
.
的形式提供。
这样做
response = stub.rpc_call(req, {metadata: {key1: value1, key2: value2}})
你可以通过阅读grpc rspec代码找到正确的用法
如何通过grpc ruby客户端添加元数据?示例代码片段会有所帮助。
元数据是任何方法调用的可选参数。例如:
metadata = { 'key' : 'value' }
response = service.method(argument, metadata: metadata)
您需要将元数据作为带有键 metadata
的哈希值传递。
在服务器端,假设您有 your_method(your_req, _call)
,元数据将以 _call.metadata
.
这样做
response = stub.rpc_call(req, {metadata: {key1: value1, key2: value2}})
你可以通过阅读grpc rspec代码找到正确的用法