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

feat: 🎸 支持多版本能力:根据不同路由映射不同的Version版本。 #1429

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

heimanba
Copy link
Contributor

Ⅰ. 支持多版本能力

场景是 在微前端的场景下一个主应用需要管理多个微应用, 实现根据不同路由映射不同的Version前端 版本

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.52%. Comparing base (ef31e09) to head (0186791).
Report is 167 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1429      +/-   ##
==========================================
+ Coverage   35.91%   43.52%   +7.61%     
==========================================
  Files          69       76       +7     
  Lines       11576    12320     +744     
==========================================
+ Hits         4157     5362    +1205     
+ Misses       7104     6622     -482     
- Partials      315      336      +21     

see 69 files with indirect coverage changes

Comment on lines 75 to 76
ctx.SetContext(config.XPreHigressTag, "")
ctx.SetContext(grayConfig.BackendGrayTag, "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方的逻辑是不是有问题,如果versionPredicates一个都没匹配上呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方的逻辑是不是有问题,如果versionPredicates一个都没匹配上呢?

这个context 用于设置cookie哈,如果设置多版本,除了设置了skippedPathPrefixes以及skippedByHeaders之外,所有请求都会经过插件处理。不过这段代码优化下,不需要设置为 空字符串,但是需要在使用的时候判断下,否则会报panic异常。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 XPreHigressTag 的意思是说上一次请求所命中的版本吗?BackendGrayTag 只是给后端应用或者中间监控组件用来标识命中了哪个版本的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 XPreHigressTag 的意思是说上一次请求所命中的版本吗?BackendGrayTag 只是给后端应用或者中间监控组件用来标识命中了哪个版本的?

是的,如果不是多版本,这两个都会记录在Cookie中。多版本就不依赖cookie了

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多版本不依赖Cookie的原因是靠path匹配可以稳定的确定目标版本,所以不用知道前一次是命中了哪个版本?

如果是的话,那要是命中的路由没有匹配到多版本的path prefix呢,也就是说多版本的path prefix没有覆盖所有的请求场景?

Copy link
Contributor Author

@heimanba heimanba Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多版本不依赖Cookie的原因是靠path匹配可以稳定的确定目标版本,所以不用知道前一次是命中了哪个版本?

因为多版本所有的资源请求(除了ajax等除外)每次都会走一次灰度的 判断逻辑。

如果是的话,那要是命中的路由没有匹配到多版本的path prefix呢,也就是说多版本的path prefix没有覆盖所有的请求场景?

如果没有并命中 到多版本的 path prefix,则会使用当前的Version, Version是一个兜底的逻辑

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

Successfully merging this pull request may close these issues.

3 participants