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

change: no longer use r3 for routing implementation #681

Closed
membphis opened this issue Oct 12, 2019 · 5 comments · Fixed by #725
Closed

change: no longer use r3 for routing implementation #681

membphis opened this issue Oct 12, 2019 · 5 comments · Fixed by #725
Labels
Milestone

Comments

@membphis
Copy link
Member

membphis commented Oct 12, 2019

大家好,我准备放弃使用 r3 来实现路由。原因有一下几个:

  1. r3 的匹配,因为底层使用正则,所以匹配效率相比 radixtree 和 trietree 这种要低很多
  2. r3 的匹配,目前不支持迭代器,所以当我们无法完成匹配优先级一类的事情
  3. r3 的匹配因为不支持回调或迭代器,所以导致属性匹配只能用标准 c 实现,所以在属性匹配上无法使用一些高级特性。

目前使用的 resty-radixtree 是没有这些问题的。

我相信有些同学肯定会问,如果我的业务需求上必须要使用正则方式匹配 uri ,这时候 resty-radixtree 是不是就不能满足呢?

比如有这样一个 API: /v1/user/1, 前面 /v1/user 分别代表前缀,后面是 user 的 id,是个整数。

在 r3 中是这么写:
/v1/user/{id:[0-9]+}

在 resty-radixtree 中也可以实现,更多参考文档。虽然这么做看似更复杂,但好处是我们可以享用 radixtree 的高效(至少比 r3 有 10 倍的性能差别)
{path = "/v1/user/*", vars = {"request_uri", "~~", [[\/v1\/user\/\d+]]}}

如果您喜欢或者不喜欢,都欢迎留言。

@nic-chen
Copy link
Member

支持,只要满足各种常见场景,当然更喜欢高性能的。

@moonming
Copy link
Member

we can discard r3 in 1.0 version.

@supermario1990
Copy link
Member

赞成,只保留最正确的选择。

@soulsoul
Copy link
Member

+1,

@moonming moonming added this to the 1.0 milestone Oct 14, 2019
@membphis
Copy link
Member Author

we can discard r3 in 1.0 version.

I finally decided to do this in version 0.9. The 0.9 version of the goal is to reduce the difficulty of deployment, which makes it easier to support more operating systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants