Skip to content

Commit

Permalink
chore: add comments for RouterMetaExtractor (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppzqh authored Mar 31, 2023
1 parent 2f5e010 commit e75192c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ In order to match the rules defined in the VirtualService we need to specify the
For example: set the key and value to "stage" and "canary" to match the above rules defined in VirtualService.

* We can first define a MetaExtractor and pass it to `RouterMiddleware` through `xdssuite.WithRouterMetaExtractor`.
* Notice: If RouterMetaExtractor is not configured, metainfo.GetAllValues will be used by default.
```
var (
routeKey = "stage"
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ spec:
比如:将 key 和 value 设置为“stage”和“canary”,以匹配 VirtualService 中定义的上述规则。

* 我们可以先定义一个元信息提取方法,并通过 `xdssuite.WithRouterMetaExtractor` 传入到 `RouterMiddleware` 中。
* 注意:若未配置 RouteMetaExtractor,默认会使用 metainfo.GetAllValues 来获取。
```
var (
routeKey = "stage"
Expand Down
2 changes: 1 addition & 1 deletion xdssuite/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type routerMetaExtractor func(context.Context) map[string]string

// Options for xds suite
type Options struct {
routerMetaExtractor routerMetaExtractor
routerMetaExtractor routerMetaExtractor // use metainfo.GetAllValues by default.
}

func (o *Options) Apply(opts []Option) {
Expand Down

0 comments on commit e75192c

Please sign in to comment.