使用动态消息作为参数的gRPC [英] gRPC with dynamic messages as an argument

查看:136
本文介绍了使用动态消息作为参数的gRPC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了protobuf支持动态创建动态消息之后,我试图创建一个返回动态消息的gRPC服务.(例如,在数据库中返回一行但仅在运行时才知道该模式的服务)

After reading that protobuf supports creation of dynamic messages on the fly, I am trying to create a gRPC service that returns a dynamic message. (e.g. a service that returns a row in database but the schema is only known at run time)

有可能吗,我该如何构造.proto?

Is it possible and how would I construct the .proto for that?

谢谢.

推荐答案

在Java中,有一个名为

In Java there is a special object called DynamicMessage which can take a descriptor and send that. If you can get the descriptor at runtime you can get it that way.

虽然不完全符合proto的精神,但是您可以使用

Also, while not exactly in the spirit of proto, you can represent arbitrary structured data using struct.proto.

这篇关于使用动态消息作为参数的gRPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆