Skip to content

Commit 818131b

Browse files
code4Ytoddbaert
andauthored
docs: document setProviderAndWait in README (open-feature#610)
* Update setProviderAndWait in README.md Signed-off-by: Yash <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent bdddeb1 commit 818131b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void example(){
104104

105105
// configure a provider
106106
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
107-
api.setProvider(new InMemoryProvider(myFlags));
107+
api.setProviderAndWait(new InMemoryProvider(myFlags));
108108

109109
// create a client
110110
Client client = api.getClient();
@@ -140,10 +140,23 @@ Look [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D
140140
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.
141141

142142
Once you've added a provider as a dependency, it can be registered with OpenFeature like this:
143+
144+
#### Synchronous
145+
146+
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:
147+
148+
```java
149+
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
150+
api.setProviderAndWait(new MyProvider());
151+
```
152+
153+
#### Asynchronous
154+
155+
To register a provider in a non-blocking manner, you can use the `setProvider` method as shown below:
143156

144157
```java
145158
OpenFeatureAPI.getInstance().setProvider(new MyProvider());
146-
```
159+
```
147160

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

210223
Clients can be given a name.
211224
A name is a logical identifier which can be used to associate clients with a particular provider.
212-
If a name has no associated provider, the global provider is used.
225+
If a name has no associated provider, the global provider is used.
213226

214227
```java
215228
FeatureProvider scopedProvider = new MyProvider();
@@ -225,6 +238,9 @@ Client clientDefault = OpenFeatureAPI.getInstance().getClient();
225238
Client clientNamed = OpenFeatureAPI.getInstance().getClient("clientForCache");
226239
```
227240

241+
Named providers can be set in a blocking or non-blocking way.
242+
For more details, please refer to the [providers](#providers) section.
243+
228244
### Eventing
229245

230246
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.

0 commit comments

Comments
 (0)