Microsoft Bond架构演变最佳实践(Microsoft Bond schema evolution best practices)
Microsoft Bond是否有一些关于模式如何随时间演变的最佳实践? 我想确保我们遵循最佳实践,以便我们具有双向兼容性(即允许我们的Bond类型将旧版本发展到当前版本,以及向后兼容性允许从较新版本转换回旧版本)。 我没有在文档中具体说明这一点(例如https://microsoft.github.io/bond/manual/bond_cs.html或https://microsoft.github.io/bond/manual/compiler.html#idl -syntax ),尽管其他序列化框架(例如Avro)在其文档中明确详细说明了这一点。
对于它的价值,我们用.NET编写(C#/ F#)并打算最初使用CompactBinaryWriter和CompactBinaryReader格式。
例如,我想象一下这些方面的一些指导:
- 字段名称可以随着时间的推移而变化,因为字段序数用于字段解析,而不是直接名称(SimpleJSON除外)。 我相信这是真的,是吗?
- 添加新的“必需”字段需要您为该字段指定默认值
- 如果旧版本分配了默认值,则删除较新版本中的字段是可以的
- 那么改变一个领域的类型呢? 例如,字段是否可以从版本1中的字符串字段更改为版本2中的int64? 它可以从字符串更改为自定义联合(具有可选字段的自定义类型)吗?
- 还有其他建议吗?
谢谢!
如果有这种类型的Microsoft Bond问题有任何活跃的论坛社区,我也会感兴趣,我无法找到一个......
Does Microsoft Bond have some best practices on how schemas evolve over time? I want to make certain we follow best practices such that we have 2 way compatibility (i.e. allowing our Bond types to evolve older versions to the current version, as well as backward compatibility allowing conversion from a newer version back to an older version). I don't see this addressed specifically in the documentation (e.g. https://microsoft.github.io/bond/manual/bond_cs.html nor https://microsoft.github.io/bond/manual/compiler.html#idl-syntax ), though other serialization frameworks such as Avro have this explicitly detailed in their documentation.
For what it's worth, we are writing in .NET (C#/F#) and intend to use the CompactBinaryWriter and CompactBinaryReader formats initially.
For example, I imagine some guidance along these lines:
- names of fields can change over time since the field ordinals are used for field resolution, not the names directly (except in SimpleJSON). I believe this true, is it?
- adding a new "required" field requires you give the field a default value
- removing a field in a newer version is okay, provided older versions had a default value assigned
- what about changing the type of a field? For example, can a field change from an string field in version 1 to a int64 in version 2? Can it change from a string to a custom union (custom type with optional fields)?
- any other recommendations?
Thank you!
would also be interested if there is any active forum community for this type of Microsoft Bond question, i wasn't able to find one...
原文:https://stackoverflow.com/questions/41860787
最满意答案
使用
$location.path()
来自文档 :
$ location服务解析浏览器地址栏中的URL(基于window.location),并使URL可供您的应用程序使用。
...
Getter和setter方法
// get the current path $location.path();
在控制器中使用
angular.module("app").controller("RecordsController", function($http, $routeParams, $location){ var path = $location.path(); // Do something with `path` ... });
演示
Use
$location.path()
from the docs:
The $location service parses the URL in the browser address bar (based on window.location) and makes the URL available to your application.
...
Getter and setter methods
// get the current path $location.path();
To use in your controller
angular.module("app").controller("RecordsController", function($http, $routeParams, $location){ var path = $location.path(); // Do something with `path` ... });
Demo
相关问答
更多-
该错误表示当/ Angular首次尝试使用它时,控制器尚未实例化。 我的猜测是你在ngRoute定义中引用控制器,而ngRoute模块试图在显示你的视图之前覆盖控制器依赖。 如果您要更新问题以包含路由配置,那可能会更加明显。 工作(或非工作)的Plnkr.co演示会更好。 I created an issue on Github for this: https://github.com/angular/angular.js/issues/11384. Turns out this scenario is n ...
-
在不知道确切用例的情况下,我的方法是定义一个新的范围属性,例如play : "=" (将视频结束时设置为停止),以及$observe attrs.play或$scope.$watch "play"它。 在模板中,将其绑定到由控制器触发的$ scope变量。
这是一个使用双向绑定的plunker,请注意您不必做任何事情: http://plnkr.co/edit/3OI801KcvYVoySDvcm8i? ... -
控制器未被调用(Controller not being called)[2023-02-13]
要创建控制器,您必须: angular.module('yourApp').controller('homeIndexController', function () { }); 这告诉角度“嘿,我有一个名为'homeIndexController'的控制器,随时可以在某处使用它。” To create a controller, you have to do: angular.module('yourApp').controller('homeIndexController', function () ... -
使用$location.path() 来自文档 : $ location服务解析浏览器地址栏中的URL(基于window.location),并使URL可供您的应用程序使用。 ... Getter和setter方法 // get the current path $location.path(); 在控制器中使用 angular.module("app").controller("RecordsController", function($http, $routeParams, $location){ ...
-
由于您的视图是嵌套的,因此您需要具体应将子状态视图插入父状态视图的位置。 根据您在问题中提供的代码,您的父状态视图如下所示 该ui-view内部没有ui-view ,ui-router也不知道你希望子视图去哪里......因此它不会渲 ...
-
所以问题是我如何构建我的模块。 我不能确切地告诉你我做错了什么,因为我还不清楚模块是如何工作的。 我做的是减少应用程序,直到我开始工作并逐个添加东西,直到我发现破坏应用程序的东西。 So the problem was how I was constructing my module. I can't tell you exactly what I did wrong because I don't yet understand exactly how modules work. What I did wa ...
-
如果您已经在路线中定义了控制器,则不需要在html模板中定义控制器,使用值形式html模板删除ng-controller属性然后运行它将只运行一次 if you already define your controller in route you dont need to define controller in html template remove the ng-controller attribute with value form html template then run it will r ...
-
可能是错的,因为主页不在描述中,但我猜在主页中,你缺少ng-view指令。 因此,不能注入模板。 你应该有类似的东西: 或者,如果你body标签下已经有一些元素: ... Might be wrong because the home page is not in the description, but I'm guessing that in the home page, ...
-
从角度服务调用角度路径以加载新视图和控制器(invoking an angular route from angular service to load a new view and controller)[2021-08-11]
应该能够使用$location.path('/search/query')来做到这一点 function getSearchResults(searchRequest) { return $http.post('search/query', searchRequest, {}).then(function (response) { myEsResults = response.data; $location.path('/search/query'); ...