Skip to content

[RFC]feat: enhance transformer plugin by adding a set-based requirement check#3495

Open
rayne-Li wants to merge 4 commits intoalibaba:mainfrom
rayne-Li:feat/trans_enhance
Open

[RFC]feat: enhance transformer plugin by adding a set-based requirement check#3495
rayne-Li wants to merge 4 commits intoalibaba:mainfrom
rayne-Li:feat/trans_enhance

Conversation

@rayne-Li
Copy link

@rayne-Li rayne-Li commented Feb 13, 2026

Ⅰ. Describe what this PR did

transformer插件目前有丰富的转换逻辑, 转换相关的功能符合我的使用场景, 但是目前我希望在add header:A时, 可以判断header中其他的key:B是否存在再进行添加(而非key:A本身)

因此我实现了一个基于sets的类似k8s labelSelector风格的校验机制, 它实现了例如: 当model不存在在headers中时才添加routing-strategy这个header

reqRules:
- headers:
  - key: "routing-strategy"
    requirement:
      key: "model"
      operator: "DoesNotExist" // Exists DoesNotExist In NotIn
    value: "random"
  operate: "add"

目前代码逻辑仅对kvHandler的add功能生效, 理论上任何一个operator都可以加上类似的条件判断机制, 如果社区认为这种方式是一个合理的必要的拓展, 我乐意继续完善add之外的功能


Ⅰ. Describe what this PR did

The transformer plug-in currently has rich conversion logic, and the conversion-related functions are in line with my usage scenarios, but currently I hope that when adding header:A, I can determine whether other key:B in the header exists before adding it (instead of key:A itself)

Therefore, I implemented a verification mechanism based on sets similar to k8s labelSelector style. It implements, for example: only add the routing-strategy header when the model does not exist in the headers.

reqRules:
- headers:
  - key: "routing-strategy"
    requirement:
      key: "model"
      operator: "DoesNotExist" // Exists DoesNotExist In NotIn
    value: "random"
  operate: "add"

At present, the code logic only takes effect for the add function of kvHandler. In theory, any operator can add a similar conditional judgment mechanism. If the community believes that this method is a reasonable and necessary expansion, I will be happy to continue to improve functions other than add.

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants