Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document setProviderAndWait in README #610

Merged
merged 5 commits into from
Sep 14, 2023
Merged
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
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
Loading