[英]Google.Cloud.AppEngine.V1 client libraries and traffic splitting in .NET
I am trying to use the Client Libraries provided by Google to move traffic from one version of an app in AppEngine to another.我正在尝试使用 Google 提供的客户端库将流量从 AppEngine 中的一个应用程序版本转移到另一个版本。 However, the documentation for doing this just talks about using the rest API and not the client libraries.
但是,执行此操作的文档仅讨论使用 rest API 而不是客户端库。
Here is some example code:这是一些示例代码:
var servicesClient = Google.Cloud.AppEngine.V1.ServicesClient.Create();
var updateServiceRequest = new UpdateServiceRequest();
updateServiceRequest.Name = "apps/myProject/services/myService";
var updateMask = new Google.Protobuf.WellKnownTypes.FieldMask();
updateServiceRequest.UpdateMask = updateMask;
// See below for what should go here...
var updateResponse = servicesClient.UpdateService(updateServiceRequest);
My question is what format do I use for the update mask?我的问题是更新掩码使用什么格式? According to the documentation I should put in:
split {"split": { "allocations": { "newVersion": 1 } } }
But when I try: updateMask.Paths.Add(@"split { ""split"": { ""allocations"": { ""myNewVersion"": 1 } } }");
根据我应该输入的文档:
split {"split": { "allocations": { "newVersion": 1 } } }
但是当我尝试时: updateMask.Paths.Add(@"split { ""split"": { ""allocations"": { ""myNewVersion"": 1 } } }");
... I get the exception: ...我得到例外:
"This operation is only supported on the following field(s): [labels, migration_config,.network_settings, split, tag_to_target_map], but got field(s): [split { "split": { "allocations": { "myNewVersion": 1 } } }] from the update request.
Any ideas where I should put the details of the split in the field mask object?有什么想法我应该把拆分的细节放在字段掩码 object 中吗? The property Paths just seems to be a collection of strings.
属性 Paths 似乎只是字符串的集合。
The examples for these libraries in Google's doco is pretty poor:-( Google 的 doco 中这些库的示例非常糟糕:-(
I raised a support ticket with Google and despite them suggesting a solution which didn't work exactly (due to trying to assign a string to the UpdateMask which needs a FieldMask object), I managed to use it to find the correct solution.我向 Google 提出了支持票,尽管他们提出了一个不完全有效的解决方案(由于试图将字符串分配给需要 FieldMask 对象的 UpdateMask),但我设法使用它找到了正确的解决方案。
The code should be:代码应该是:
// appService is a previously retrieved Service object from the ListServices method
var updateServiceRequest = new UpdateServiceRequest();
updateServiceRequest.Name = appService.Name;
updateServiceRequest.UpdateMask = new Google.Protobuf.WellKnownTypes.FieldMask();
updateServiceRequest.UpdateMask.Paths.Add("split");
appService.Split.Allocations.Clear();
appService.Split.Allocations["newServiceVerison"] = 1;
updateServiceRequest.Service = appService;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.