Class VariantRouter.Builder<T>

java.lang.Object
cloud.opencode.base.feature.proxy.VariantRouter.Builder<T>
Type Parameters:
T - the variant type | 变体类型
Enclosing class:
VariantRouter<T>

public static class VariantRouter.Builder<T> extends Object
Builder for VariantRouter VariantRouter构建器
Since:
JDK 25, opencode-base-feature V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • variant

      public VariantRouter.Builder<T> variant(String variantId, T implementation)
      Add a variant with equal percentage distribution 添加具有平均百分比分布的变体
      Parameters:
      variantId - the variant identifier | 变体标识符
      implementation - the variant implementation | 变体实现
      Returns:
      this builder | 此构建器
    • variant

      public VariantRouter.Builder<T> variant(String variantId, T implementation, int percentage)
      Add a variant with specified percentage 添加具有指定百分比的变体
      Parameters:
      variantId - the variant identifier | 变体标识符
      implementation - the variant implementation | 变体实现
      percentage - the traffic percentage (0-100) | 流量百分比 (0-100)
      Returns:
      this builder | 此构建器
    • variant

      public VariantRouter.Builder<T> variant(String variantId, Supplier<T> supplier, int percentage)
      Add variant from supplier 从供应器添加变体
      Parameters:
      variantId - the variant identifier | 变体标识符
      supplier - the variant supplier | 变体供应器
      percentage - the traffic percentage | 流量百分比
      Returns:
      this builder | 此构建器
    • defaultVariant

      public VariantRouter.Builder<T> defaultVariant(String variantId)
      Set the default variant 设置默认变体
      Parameters:
      variantId - the default variant ID | 默认变体ID
      Returns:
      this builder | 此构建器
    • salt

      public VariantRouter.Builder<T> salt(String salt)
      Set salt for consistent hashing 设置一致性哈希的盐
      Parameters:
      salt - the salt value | 盐值
      Returns:
      this builder | 此构建器
    • build

      public VariantRouter<T> build()
      Build the router 构建路由器
      Returns:
      the variant router | 变体路由器