我可以做一个云的端点(应用引擎)什么样的变化返回对象之前,我需要一个新的API的版本? (以及如何做那) [英] What changes can I make to a cloud-endpoint (app-engine) return object before I need a new API version? (and how is that done)

查看:158
本文介绍了我可以做一个云的端点(应用引擎)什么样的变化返回对象之前,我需要一个新的API的版本? (以及如何做那)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回由各种类型的许多领域的POJO对象的应用程序引擎服务端点。 Android客户端,与相应的端点库建成,接受本就好了。

I have an App-Engine service endpoint that is returning a POJO object consisting of many fields of various types. The Android client, built with the corresponding endpoint-libs, accepts this just fine.

如果我的添加的新领域到的结束的这个对象的定义,并开始返回从App引擎服务器的扩展的对象,将较旧的Andr​​oid客户接受这一点,只是忽略额外的,否则将BARF?

If I add new fields to the end of this object definition and start returning that extended object from the App-Engine servers, will older Android clients accept this and just ignore the extra, or will they barf?

我看到的支持的API,这似乎是必需的,如果我不能延长我的回报对象的不同版本的记载,但信息的如何的编写,这是很难找到。任何指针?

I see mention of support of different "versions" of an API, which seems to be required if I can't extend my return object, but information on how to write this is difficult to find. Any pointers?

或者,也许更简单... 什么是不同的信息返回到一个REST调用超过previous服务器版本,仍然是向下兼容旧客户端兼容的最好方法?像物化 -for的端点将是完美的。

Or, perhaps more simply... What is the best way to return different information to a REST call than previous server versions and still be backward compatible with older clients? Something like Objectify-for-Endpoints would be perfect.

推荐答案

如果您唯一的变化是添加剂,previously生成客户端应继续正常工作。我只是测试后台和Android客户端,他们表现得正确,当我加入一个POJO没有现场更新客户端。

If the only changes you make are additive, previously generated clients should continue to work fine. I just tested a backend and Android client and they behaved correctly when I added a field to the POJO without updating the client.

有一个有点用<一个href=\"https://developers.google.com/appengine/docs/java/endpoints/test_deploy#managing_your_backend_api_versions\"相对=nofollow>文档中的表格,让上时,你应该是递增的API版本的指导。

There is a somewhat helpful table in the documentation that gives some guidance on when you should be incrementing API versions.

相关位:


      
  • 当你想引进增量,但非重大更改,保持API的版本不变,部署在现有的API。

  •   
  • 当你介绍一个重大更改到您的API,增加API版本。

  •   

添加字段到你的POJO应该有资格作为一个增量,非重大更改。如果更改字段的名称或类型,您可能需要增加API版本。

Adding a field to your POJO should qualify as an incremental, non-breaking change. If you change the names or types of fields, you will likely need to increment the API version.

在托管多个API / App Engine的版本

的API只是个教学班,注释,所以如果你想添加一个新的API版本,只需添加一个新的类,并指定在注解不同的版本号。你可以自由地利用继承设计的类(参见多类的API )。

APIs are just classes with annotations, so if you want to add a new API version, just add a new class and specify a different version number in the annotation. You're free to make use of inheritance in designing your classes (see Multiclass APIs).

如果你把App Engine的版本不变(或总是参照默认版本),这需要改变,客户端的唯一的事情,是的版本API您正在访问。客户端库构建中的版本号,所以如果你产生了 V1 您的API客户端库,它总是会访问 V1 除非你修改源的API。如果您在API的添加剂变为 V1 V1 客户端库应继续工作(如上所述)。

If you keep the App Engine version constant (or always refer to the default version), the only thing that needs to change, client side, is the version of the API you are accessing. The client library builds in the version number, so if you generated a client library for v1 of your API, it will always access v1 of the API unless you modify the source. If you make additive changes to v1 of the API, the client library for v1 should continue to work (as noted above).

如果您修改通过App Engine版本和API的版本,事情变得有点棘手。你可以有不同的 V1 托管在应用的不同(App引擎)版本的API第默认情况下,客户端库将指向App Engine的默认版本,但是你可以在客户端库通过改变根URL重写这个指向一个特定的版本(例如: https://1-dot-myapp.appspot.com )。

If you modify both the App Engine version and API version, things get a little trickier. You can have different v1s of an API hosted on different (App Engine) versions of an app. By default, client libraries are going to point to the App Engine default version, but you can override this in the client library by changing the root URL to point to a specific version (e.g. https://1-dot-myapp.appspot.com).

我的建议是始终有code,它是向客户发货指向你的默认应用程序引擎的版本(主要的例外是,如果你有一些内部测试版本您的应用程序可以很容易地更新)。如果你增加了App Engine的版本,确保包括您要支持到该部署中的所有API的版本。

My recommendation is to always have code that's shipped to customers point at your default App Engine version (the major exception would be if you have some dogfood version of your app that can be easily updated). If you increment the App Engine version, make sure to include all API versions that you wish to support into that deployment.

这篇关于我可以做一个云的端点(应用引擎)什么样的变化返回对象之前,我需要一个新的API的版本? (以及如何做那)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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