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

优化系统启动时主题端的链接访问 #3254

Closed
guqing opened this issue Feb 8, 2023 · 1 comment · Fixed by #3300
Closed

优化系统启动时主题端的链接访问 #3254

guqing opened this issue Feb 8, 2023 · 1 comment · Fixed by #3300
Assignees
Labels
area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement.
Milestone

Comments

@guqing
Copy link
Member

guqing commented Feb 8, 2023

Your current Halo version

latest

Describe this feature

如果文章多系统刚启动时需要很长时间才能访问,主要是因为 Reconciler 在运行,只要运行到某个资源的 Reconciler 时才能注册路由因此很长时间才能访问到。

优化方案:
能通过注册 pattern 作为路由的就注册 pattern 这样系统启动时不会影响到资源的访问。

Additional information

/kind improvement
/area core
/milestone 2.3.x
/assign

@f2c-ci-robot f2c-ci-robot bot added the kind/improvement Categorizes issue or PR as related to a improvement. label Feb 8, 2023
@f2c-ci-robot f2c-ci-robot bot added this to the 2.3.x milestone Feb 8, 2023
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Feb 8, 2023
@JohnNiang
Copy link
Member

More refs:

JohnNiang pushed a commit that referenced this issue Feb 24, 2023
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
能通过注册 pattern 作为路由的就直接注册 pattern 以避免 Reconciler 还没结束而无法注册路由导致的访问问题。
1. 文章、标签、分类的 permalink 规则会记录在对应 extension  的 annotations 中为  `content.halo.run/permalink-pattern: some-pattern` ,当系统设置中路由规则改变时会刷一遍这些资源的 `content.halo.run/permalink-pattern` annotation。
3. 自定义页面的访问是通过 SinglePageRoute 控制,它会在 single page 添加、更新、删除时维护 quickRouteMap 的集合,在路由到它时直接通过 request path 查找 map key,找到则直接返回 HandleFunction。
4. 除了自定义页面外其他都是通过 ThemeCompositeRouterFunction 作为路由管理器,系统启动时文章等的 RouterFunction 会被生成并缓存到 cachedRouters 的一个 List 集合中,当路由规则改变会清理它重新赋值。

#### Which issue(s) this PR fixes:

Fixes #3254 

#### Special notes for your reviewer:
how  to test it?
1.  测试首页、文章、标签、分类、归档页、自定义页面和作者页等的访问。
6. 测试添加、删除资源和修改系统路由规则后上述资源的访问。
7. 测试分页路径如 /tags/slug/page/1 的访问。

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
 优化启动时页面长时间无法访问的问题
```
@ruibaby ruibaby modified the milestones: 2.3.x, 2.3.0 Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants