Christoph Deppisch created CAMEL-25333:
------------------------------------------

             Summary: Add component for feature flag evaluation using 
OpenFeature specification
                 Key: CAMEL-25333
                 URL: https://issues.apache.org/jira/browse/CAMEL-25333
             Project: Camel
          Issue Type: New Feature
            Reporter: Christoph Deppisch


Add a new {{camel-openfeature}} component that provides feature flag evaluation 
capabilities using the [OpenFeature specification|https://openfeature.dev/] 
([spec|https://github.com/open-feature/spec]).

The component provides both an endpoint and a language implementation for Camel 
(similar to the pattern used by {{{}camel-typesafe-ai{}}}), enabling feature 
flag evaluation in EIPs such as choice, message-dispatcher, 
content-based-router, and filter.

*Endpoint URI*
{noformat}
openfeature:name[?options]{noformat}
The mandatory {{name}} is a logical name that resolves to a feature flag 
provider configuration and its feature flag specification.

*Endpoint Parameters*
 * {{flagKey}} | The name of the feature flag definition to evaluate
 * {{resultProperty}} | Stores the evaluation result as an Exchange property 
with the given name. When set, the original message body is preserved. 
Otherwise the evaluation result is set as the new message body
 * {{configuration}} | Default provider configuration shared by OpenFeature 
endpoints
 * {{host}} | Optional remote flagd service host
 * {{port}} | Optional remote flagd service port
 * {{flags}} | A JSON object defining feature flags (inline)
 * {{flagsResource}} | Camel resource URI pointing to a feature flag definition 
resource

*Core Capabilities*

The OpenFeature endpoint/language evaluates feature flags using a configured 
provider and stores the result as:
 * An Exchange property (when {{resultProperty}} is set), or
 * The Exchange body (default)

Each evaluation requires a mandatory {{flagKey}} identifying the feature flag 
definition. An optional evaluation context (key-value pairs) can be provided as 
input.

*Evaluation Types*
 * *Boolean evaluation* ({{{}getBooleanValue(){}}}): Returns a boolean for 
isEnabled checks, with an optional default value. Used for detour/toggle 
patterns.
 * *String evaluation* ({{{}getStringValue(){}}}): Returns a string variant 
(e.g., "v1", "v2") based on the evaluation context. Used for A/B testing, 
fractional targeting, and targeted rollouts.

*Language Expression*

The OpenFeature language can be used directly in EIPs for concise flag 
evaluation:
{code:java}
from("direct:start")
    .filter().language("openfeature", "enrichment-enabled")
        .to("direct:enrich-order")
    .end()
    .to("direct:process-order");{code}
*Supported Providers*

The component should support the following OpenFeature providers out of the box:
 * {*}InMemory provider{*}: Feature flag definitions are provided 
programmatically as part of the route setup. Useful for testing and simple 
configurations.
 * {*}Flagd provider{*}: Evaluates flags using [flagd|https://flagd.dev/]. 
Supports both:
 ** Local file-based flag definitions
 ** gRPC connection to a remote flagd service

*Use Cases*
 * {*}Detour pattern{*}: Boolean flag controls whether a processing step is 
enabled or skipped (e.g., {{{}enrichment-enabled{}}}).
 * {*}Fractional A/B routing{*}: Traffic is split between variants based on a 
stable hash of the targeting key (e.g., 90/10 split between legacy and new 
routing algorithms).
 * {*}Targeted rollout{*}: Different flag values based on evaluation context 
attributes (e.g., enterprise/VIP customers get v2, others get v1).

*Example Flag Definitions (flagd)*
{code:json}
{
  "flags": {
    "enrichment-enabled": {
      "state": "ENABLED",
      "variants": { "on": true, "off": false },
      "defaultVariant": "on"
    },
    "new-routing-algorithm": {
      "state": "ENABLED",
      "variants": {
        "legacy": "content-based-router",
        "new": "dynamic-router"
      },
      "defaultVariant": "legacy",
      "targeting": {
        "fractional": [["legacy", 90], ["new", 10]]
      }
    },
    "hazmat-compliance-v2": {
      "state": "ENABLED",
      "variants": { "v1": "v1", "v2": "v2" },
      "defaultVariant": "v1",
      "targeting": {
        "if": [
          { "in": [{ "var": "customer_tier" }, ["ENTERPRISE", "VIP"]] },
          "v2",
          "v1"
        ]
      }
    }
  }
}{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to