Skip to content

Commit

Permalink
fix: getState now mandatory on EventProvider (open-feature#531)
Browse files Browse the repository at this point in the history
* fix: getState mandatory on EventProvider

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>

* fixup: update test class

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>

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

Co-authored-by: Giovanni Liva <giovanni.liva@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>

---------

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: Giovanni Liva <giovanni.liva@dynatrace.com>
  • Loading branch information
toddbaert and thisthat authored Aug 4, 2023
1 parent 8789f90 commit 37fd2be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/dev/openfeature/sdk/EventProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
*/
public abstract class EventProvider implements FeatureProvider {

/**
* {@inheritDoc}
*/
@Override
public abstract ProviderState getState();

private TriConsumer<EventProvider, ProviderEvent, ProviderEventDetails> onEmit = null;

/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/dev/openfeature/sdk/FeatureProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ default List<Hook> getProviderHooks() {
* if they have special initialization needed prior being called for flag
* evaluation.
* <p>
* It is ok, if the method is expensive as it is executed in the background. All
* It is ok if the method is expensive as it is executed in the background. All
* runtime exceptions will be
* caught and logged.
* </p>
Expand All @@ -46,7 +46,7 @@ default void initialize(EvaluationContext evaluationContext) throws Exception {
* Providers can overwrite this method, if they have special shutdown actions
* needed.
* <p>
* It is ok, if the method is expensive as it is executed in the background. All
* It is ok if the method is expensive as it is executed in the background. All
* runtime exceptions will be
* caught and logged.
* </p>
Expand All @@ -57,7 +57,11 @@ default void shutdown() {

/**
* Returns a representation of the current readiness of the provider.
* Providers which do not implement this method are assumed to be ready immediately.
* If the provider needs to be initialized, it should return {@link ProviderState#NOT_READY}.
* If the provider is in an error state, it should return {@link ProviderState#ERROR}.
* If the provider is functioning normally, it should return {@link ProviderState#READY}.
*
* <p><i>Providers which do not implement this method are assumed to be ready immediately.</i></p>
*
* @return ProviderState
*/
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/dev/openfeature/sdk/EventProviderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public ProviderEvaluation<Value> getObjectEvaluation(String key, Value defaultVa
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getObjectEvaluation'");
}

@Override
public ProviderState getState() {
return ProviderState.READY;
}
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 37fd2be

Please sign in to comment.