gRPC/Protobuf界面版本控制 [英] gRPC / Protobuf interface versioning

查看:183
本文介绍了gRPC/Protobuf界面版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我们使用gRCP/Protobuf连接许多应用程序. 这些应用程序是由自己的团队以自己的速度开发和发布的.随着时间的流逝,同一应用程序的不同版本(例如,在用户PC上安装了桌面应用程序)会在定义的界面上使用不同的版本.

Let's say we use gRCP/Protobuf to connect many application. Those application are developped and released at their own team, with their own speed. Over time there will be different version of the the same app (e.g. desktop apps install on user PCs) that use different version on defined interface.

虽然Protobuf旨在允许向后兼容,但有没有办法知道不同点运行的接口版本?

While Protobuf is meant to allow backward compatibility, is there a way to know what version of interface is running at different points?

最简单的实现是使接口版本等于应用程序版本. 但是,由于使用了多种语言,因此在所有语言中实现应用程序版本控制并非易事.

The simplest implementation is to have interface version equal to app version. But as many languages are used, it is not trivial to implement app versioning in all of them.

那么版本接口如何让服务器知道客户端版本? 我认为服务器应该能够登录

So how version interface and let server to know client version? I think server should be able to log

AppName v.version的DATETIME连接[使用接口v.version]

DATETIME connection from AppName v.version [using interface v.version]

推荐答案

在即将发布的gRPC版本中,将有一个称为服务器反射"的新功能.这将允许客户端向服务器询问用于描述符正在使用的原始文件的描述符.客户端将知道服务器正在运行什么,而不是服务器知道客户端正在运行的版本.如果服务器描述符与客户端已经拥有的描述符匹配,则它将知道它们正在使用相同的版本.

In the upcoming versions of gRPC, there will be a new feature called Server Reflection. This will allow a client to ask the server for the Descriptors that descriptor the proto file being used. Rather than the server knowing about the version the client is running, the client will know what the server is running. If the server descriptor matches the one the client already has, then it will know that they are speaking at the same version.

它将在版本1.1中发布.

请注意,Protobuf的设计目的是让您不必这样做!如果正确设置了原型,则客户端和服务器的旧版本和新版本应该可以一起使用.

Note that Protobufs are designed so that you don't have to do this! If you set up your proto correctly, old and new versions of clients and server should work together.

这篇关于gRPC/Protobuf界面版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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