Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize(hz): sort route strictly which preventing sorting inconsistencies #921

Merged
merged 2 commits into from
May 9, 2024

Conversation

FGYFFFF
Copy link
Contributor

@FGYFFFF FGYFFFF commented Aug 18, 2023

What type of PR is this?

optimize

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • 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

(Optional) Translate the PR title into Chinese.

对路由进行严格排序,防止生成代码出现大量的 diff

(Optional) More detailed description for this PR(en: English/zh: Chinese).

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:

(Optional) The PR that updates user documentation:

@FGYFFFF FGYFFFF requested review from a team as code owners August 18, 2023 11:56
@welkeyever
Copy link
Member

/:b 这类路由和其他的静态路由分开放其实也合理,一眼看过去也清晰哪?类似:

/:aa
/:vv
/a
/b

@FGYFFFF FGYFFFF force-pushed the optimize/router_sort branch 11 times, most recently from fc8e2b3 to 7c2841f Compare April 24, 2024 13:23
@FGYFFFF FGYFFFF force-pushed the optimize/router_sort branch from 7c2841f to 637e0da Compare April 24, 2024 13:59
@FGYFFFF FGYFFFF merged commit 6f62cd9 into develop May 9, 2024
21 of 24 checks passed
@FGYFFFF FGYFFFF deleted the optimize/router_sort branch May 9, 2024 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants