Skip to content

Commit

Permalink
docs: document setProviderAndWait in README (#610)
Browse files Browse the repository at this point in the history
* Update setProviderAndWait in README.md

Signed-off-by: Yash <93548927+code4Y@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
  • Loading branch information
code4Y and toddbaert authored Sep 14, 2023
1 parent bdddeb1 commit 818131b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void example(){

// configure a provider
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProvider(new InMemoryProvider(myFlags));
api.setProviderAndWait(new InMemoryProvider(myFlags));

// create a client
Client client = api.getClient();
Expand Down Expand Up @@ -140,10 +140,23 @@ Look [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D
If the provider you're looking for hasn't been created yet, see the [develop a provider](#develop-a-provider) section to learn how to build it yourself.

Once you've added a provider as a dependency, it can be registered with OpenFeature like this:

#### Synchronous

To register a provider in a blocking manner to ensure it is ready before further actions are taken, you can use the `setProviderAndWait` method as shown below:

```java
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new MyProvider());
```

#### Asynchronous

To register a provider in a non-blocking manner, you can use the `setProvider` method as shown below:

```java
OpenFeatureAPI.getInstance().setProvider(new MyProvider());
```
```

In some situations, it may be beneficial to register multiple providers in the same application.
This is possible using [named clients](#named-clients), which is covered in more details below.
Expand Down Expand Up @@ -209,7 +222,7 @@ The Java SDK uses SLF4J. See the [SLF4J manual](https://slf4j.org/manual.html) f

Clients can be given a name.
A name is a logical identifier which can be used to associate clients with a particular provider.
If a name has no associated provider, the global provider is used.
If a name has no associated provider, the global provider is used.

```java
FeatureProvider scopedProvider = new MyProvider();
Expand All @@ -225,6 +238,9 @@ Client clientDefault = OpenFeatureAPI.getInstance().getClient();
Client clientNamed = OpenFeatureAPI.getInstance().getClient("clientForCache");
```

Named providers can be set in a blocking or non-blocking way.
For more details, please refer to the [providers](#providers) section.

### Eventing

Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.
Expand Down

0 comments on commit 818131b

Please sign in to comment.