Skip to content

Commit 37fd2be

Browse files
toddbaertthisthat
andauthored
fix: getState now mandatory on EventProvider (#531)
* fix: getState mandatory on EventProvider Signed-off-by: Todd Baert <[email protected]> * fixup: update test class Signed-off-by: Todd Baert <[email protected]> * Update src/test/java/dev/openfeature/sdk/EventProviderTest.java Co-authored-by: Giovanni Liva <[email protected]> Signed-off-by: Todd Baert <[email protected]> --------- Signed-off-by: Todd Baert <[email protected]> Co-authored-by: Giovanni Liva <[email protected]>
1 parent 8789f90 commit 37fd2be

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/main/java/dev/openfeature/sdk/EventProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
*/
1717
public abstract class EventProvider implements FeatureProvider {
1818

19+
/**
20+
* {@inheritDoc}
21+
*/
22+
@Override
23+
public abstract ProviderState getState();
24+
1925
private TriConsumer<EventProvider, ProviderEvent, ProviderEventDetails> onEmit = null;
2026

2127
/**

src/main/java/dev/openfeature/sdk/FeatureProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ default List<Hook> getProviderHooks() {
3131
* if they have special initialization needed prior being called for flag
3232
* evaluation.
3333
* <p>
34-
* It is ok, if the method is expensive as it is executed in the background. All
34+
* It is ok if the method is expensive as it is executed in the background. All
3535
* runtime exceptions will be
3636
* caught and logged.
3737
* </p>
@@ -46,7 +46,7 @@ default void initialize(EvaluationContext evaluationContext) throws Exception {
4646
* Providers can overwrite this method, if they have special shutdown actions
4747
* needed.
4848
* <p>
49-
* It is ok, if the method is expensive as it is executed in the background. All
49+
* It is ok if the method is expensive as it is executed in the background. All
5050
* runtime exceptions will be
5151
* caught and logged.
5252
* </p>
@@ -57,7 +57,11 @@ default void shutdown() {
5757

5858
/**
5959
* Returns a representation of the current readiness of the provider.
60-
* Providers which do not implement this method are assumed to be ready immediately.
60+
* If the provider needs to be initialized, it should return {@link ProviderState#NOT_READY}.
61+
* If the provider is in an error state, it should return {@link ProviderState#ERROR}.
62+
* If the provider is functioning normally, it should return {@link ProviderState#READY}.
63+
*
64+
* <p><i>Providers which do not implement this method are assumed to be ready immediately.</i></p>
6165
*
6266
* @return ProviderState
6367
*/

src/test/java/dev/openfeature/sdk/EventProviderTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public ProviderEvaluation<Value> getObjectEvaluation(String key, Value defaultVa
121121
// TODO Auto-generated method stub
122122
throw new UnsupportedOperationException("Unimplemented method 'getObjectEvaluation'");
123123
}
124+
125+
@Override
126+
public ProviderState getState() {
127+
return ProviderState.READY;
128+
}
124129
}
125130

126131
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)