Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions providers/multiprovider/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# OpenFeature Multi-Provider for Java

> **Deprecated:** This module has been superseded by the multi-provider implementation in the **core Java SDK**.
> For new projects, please use [`dev.openfeature.sdk.multiprovider.MultiProvider`](https://github.com/open-feature/java-sdk/blob/main/src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java) from the core SDK instead of this contrib module.
> This artifact remains available for backwards compatibility but may be removed in a future release.

The OpenFeature Multi-Provider wraps multiple underlying providers in a unified interface, allowing the SDK client to transparently interact with all those providers at once.
This allows use cases where a single client and evaluation interface is desired, but where the flag data should come from more than one source.

Expand All @@ -14,6 +18,11 @@ Some examples:
You can use the Multi-Provider to automatically fall back to a local configuration if an external vendor provider goes down, rather than using the default values.
By using the FirstSuccessfulStrategy, the Multi-Provider will move on to the next provider in the list if an error is thrown.

> **Recommended replacement:** For new integrations, see the multi-provider in the core SDK:
>
> - Class: [`dev.openfeature.sdk.multiprovider.MultiProvider`](https://github.com/open-feature/java-sdk/blob/main/src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java)
> - Documentation: refer to the [Java SDK README](https://github.com/open-feature/java-sdk#openfeature-java-sdk) Javadoc.

## Strategies

The Multi-Provider supports multiple ways of deciding how to evaluate the set of providers it is managing, and how to deal with any errors that are thrown.
Expand Down Expand Up @@ -49,6 +58,9 @@ Rather than making assumptions about when to use a provider’s result and when

## Installation

> **Note:** The following coordinates are kept for existing users of the contrib multi-provider.
> New projects should prefer the core SDK dependency and its `dev.openfeature.sdk.providers.multiprovider.MultiProvider` implementation.

<!-- x-release-please-start-version -->

```xml
Expand All @@ -63,6 +75,8 @@ Rather than making assumptions about when to use a provider’s result and when
<!-- x-release-please-end-version -->

## Usage
Legacy usage: This example shows how to use the contrib multi-provider.
For new code, use dev.openfeature.sdk.providers.multiprovider.MultiProvider from the core SDK and follow the examples in the Java SDK README.

Usage example:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
import lombok.extern.slf4j.Slf4j;

/**
* First match strategy. Return the first result returned by a provider. Skip providers that
* indicate they had no value due to FLAG_NOT_FOUND. In all other cases, use the value returned by
* the provider. If any provider returns an error result other than FLAG_NOT_FOUND, the whole
* evaluation should error and “bubble up” the individual provider’s error in the result. As soon as
* a value is returned by a provider, the rest of the operation should short-circuit and not call
* the rest of the providers.
* First Match strategy.
*
* <p>Return the first result returned by a provider. Skip providers that indicate they had no
* value due to {@code FLAG_NOT_FOUND}. In all other cases, use the value returned by the
* provider. If any provider returns an error result other than {@code FLAG_NOT_FOUND}, the whole
* evaluation should error and “bubble up” the individual provider’s error in the result. As soon
* as a value is returned by a provider, the rest of the operation should short-circuit and not
* call the rest of the providers.</p>
*
* @deprecated Use {@link dev.openfeature.sdk.multiprovider.FirstMatchStrategy}
* from the core Java SDK instead.
*/
@Slf4j
@NoArgsConstructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In addition to the @deprecated Javadoc tag, you should also add the @Deprecated annotation to the class. This will cause the compiler to generate warnings when the class is used, which is crucial for communicating deprecations effectively.

@NoArgsConstructor
@Deprecated

@Deprecated
public class FirstMatchStrategy implements Strategy {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
import lombok.extern.slf4j.Slf4j;

/**
* First Successful Strategy. Similar to “First Match”, except that errors from evaluated providers
* do not halt execution. Instead, it will return the first successful result from a provider. If no
* provider successfully responds, it will throw an error result.
* First Successful strategy.
*
* <p>Similar to “First Match”, except that errors from evaluated providers do not halt execution.
* Instead, it will return the first successful result from a provider. If no provider successfully
* responds, it will throw an error result.</p>
*
* @deprecated Use {@link dev.openfeature.sdk.multiprovider.FirstSuccessfulStrategy}
* from the core Java SDK instead.
*/
@Slf4j
@NoArgsConstructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In addition to the @deprecated Javadoc tag, you should also add the @Deprecated annotation to the class. This will cause the compiler to generate warnings when the class is used, which is crucial for communicating deprecations effectively.

@NoArgsConstructor
@Deprecated

@Deprecated
public class FirstSuccessfulStrategy implements Strategy {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;

/** Provider implementation for Multi-provider. */
/**
* Multi-provider implementation that composes multiple providers.
*
* <p>This implementation lives in the contrib repository and is kept for backwards compatibility
* with existing users.</p>
*
* @deprecated Use {@link dev.openfeature.sdk.multiprovider.MultiProvider}
* from the core Java SDK instead.
*/
@Slf4j

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In addition to the @deprecated Javadoc tag, you should also add the @Deprecated annotation to the class. This will cause the compiler to generate warnings when the class is used, which is crucial for communicating deprecations effectively.

@Slf4j
@Deprecated

@Deprecated
public class MultiProvider extends EventProvider {

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import java.util.Map;
import java.util.function.Function;

/** strategy. */
/**
* Strategy for evaluating flags across multiple providers.
*
* @deprecated Use the strategy classes in {@code dev.openfeature.sdk.multiprovider}
* from the core Java SDK instead.
*/
@Deprecated
public interface Strategy {
<T> ProviderEvaluation<T> evaluate(
Map<String, FeatureProvider> providers,
Expand Down