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

fix: getState mandatory on EventProvider #531

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
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
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>
Comment on lines +60 to +64
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a minimum we should add these docs, but I think the small breaking change below is worth adding.

*
* @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