feat: allow computed fractional bucket variants

未关闭 适合新手
#1,988 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 2 天内回复

@marcozabel 已经在做这个了。

开始于 2026年11月23日。

  • #1979 来自 @marcozabel —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

首先找到 Java 中 fractional bucketing 的实现及其测试;issue 指向 Go 实现,并将对应的 terminal-variant 测试作为行为参考。检查 variant 表达式是否在 bucketing 之前只求值一次,以及其结果类型是否会被拒绝。为计算得到的 variant 添加测试,包括一个 resolve 表达式,并确认 bucketing 仍然只取决于 bucketing 值和权重。

由索引模型根据 Issue 内容生成。

描述

A fractional bucket variant can be any JSON Logic expression, not only a literal:

{
  "state": "ENABLED",
  "defaultVariant": "blue",
  "variants": {
    "red": "#FF0000",
    "blue": "#0000FF"
  },
  "targeting": {
    "fractional": [
      [{ "cat": ["r", "ed"] }, 50],
      ["blue", 50]
    ]
  }
}
  • Evaluate each variant expression once, before bucketing, and return the result for the selected bucket.
  • Accept a primitive (string, number, boolean, null) or the resolve result as the variant. Any other result (e.g. an object or array) makes fractional return null, so the flag falls back to its default variant.
  • Bucketing doesn't change; it depends only on the bucketing value and the weights.

This may already work, or only need a variant type check adjusted. Either way, please add tests for a computed variant and for a non-primitive result.

Why: this allows the new resolve operator as a bucket variant (e.g. [{ "resolve": ["red", "SPLIT"] }, 50]), so each bucket can set its own reason and metadata.

References:

  • Go implementation: open-feature/flagd#2127 (the fractional.go change and the "fractional bucket variant is terminal" test in resolve_test.go)
  • Gherkin scenarios: open-feature/flagd-testbed#448
主要语言
Java
星标
51
派生
90
平均合并
1 天 6 小时
30 天内合并 PR
14

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-feature/java-sdk-contrib 的其他 Issue

查看 open-feature/java-sdk-contrib 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。