-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize(hz): sort route strictly which preventing sorting inconsiste…
…ncies (#921) #### What type of PR is this? <!-- Add one of the following kinds: build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) docs: Documentation only changes feat: A new feature optimize: A new optimization fix: A bug fix perf: A code change that improves performance refactor: A code change that neither fixes a bug nor adds a feature style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc) test: Adding missing tests or correcting existing tests chore: Changes to the build process or auxiliary tools and libraries such as documentation generation --> optimize #### Check the PR title. <!-- The description of the title will be attached in Release Notes, so please describe it from user-oriented, what this PR does / why we need it. Please check your PR title with the below requirements: --> - [x] This PR title match the format: \<type\>(optional scope): \<description\> - [x] The description of this PR title is user-oriented and clear enough for others to understand. - [ ] Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. [User docs repo](https://github.com/cloudwego/cloudwego.github.io) #### (Optional) Translate the PR title into Chinese. 对路由进行严格排序,防止生成代码出现大量的 diff #### (Optional) More detailed description for this PR(en: English/zh: Chinese). <!-- Provide more detailed info for review(e.g., it's recommended to provide perf data if this is a perf type PR). --> en: Strict ordering of routes to prevent generating code with lots of diffs zh(optional): 对路由进行严格排序,防止生成的路由代码出现由于顺序带来的 diff 之前的路由在排序的时候漏掉三个case: - "/:b/a": 这种情况会取 ":b" 与其他节点进行比较,导致路由生成不是按照路由首字母来排序 - "get /a", "post /a": 这种情况之前默认使用 "a" 和 "a" 进行比较,导致生成的路由 get/post 等方法可能出现不一致的顺序,从而生成代码出现 diff - 之前构建路由树的时候,结构和用户定义接口的顺序有关,导致用户添加一个接口时,生成代码顺序发生变化,针对这个情况也做了排序 - 之前漏掉对于中间节点的排序(路由组节点的排序),导致可能会出现生成代码的diff 本 pr 的修改不会影响路由注册的逻辑,但是会使得之前生成的路由代码的顺序发生改变(在idl的method特别多的时候表现明显)。 在这个问题修好之后,以后所以的 idl 都不会对 router 带来diff(除了加路由) #### (Optional) Which issue(s) this PR fixes: <!-- Automatically closes linked issue when PR is merged. Eg: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> #### (Optional) The PR that updates user documentation: <!-- If the current PR requires user awareness at the usage level, please submit a PR to update user docs. [User docs repo](https://github.com/cloudwego/cloudwego.github.io) -->
- Loading branch information
Showing
8 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters