Repository navigation
fix: getState mandatory on EventProvider - #531
Conversation
Codecov Report
@@ Coverage Diff @@
## main #531 +/- ##
=========================================
Coverage 95.36% 95.36%
Complexity 330 330
=========================================
Files 31 31
Lines 755 755
Branches 37 37
=========================================
Hits 720 720
Misses 18 18
Partials 17 17
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
4cc7e49 to
ab90798
Compare
In 3 event provider implementations, [flagd-java](open-feature/java-sdk-contrib#361 (review)), [go-feature-flag-web](open-feature/js-sdk-contrib#474 (comment)), and even my own implementation of flagd-js, authors have forgotten to properly implement `getState` (which means the SDK assumes the provider is already `READY` and doesn't run `initialize()`.) This is an easy pitfall. To help with this, I'm adding doc. We may be able to improve the interfaces to help with this, but I think this is a safe and helpful change for now. Relates to: open-feature/java-sdk#531 Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
This is an interesting idea IMO. Can you elaborate more on the user-experience of this? Does the annotation add something that developers can easily see in their IDE? Does it suppose a dev would open the source file? @thisthat |
ca8636a to
734ddc6
Compare
AFAIK, no IDE prints any special info for annotations. However, when I work on implementing an interface/abstract class I do look in the source file. Annotations are preserved in case of decompilation. It would be just a "FYI" for implementers. |
OK that's kinda what I was assuming. I still like the idea. |
734ddc6 to
ecb5a8f
Compare
| * 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> |
There was a problem hiding this comment.
At a minimum we should add these docs, but I think the small breaking change below is worth adding.
ecb5a8f to
dd26e2c
Compare
|
Approved. We can make this a breaking change and bump the minor version. Given that the eventing support is new, I assume there are only a handful of adoptions of the previous sdk version. |
6061f26 to
8541a2a
Compare
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> Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
8541a2a to
527c9f7
Compare
|
Kudos, SonarCloud Quality Gate passed!
|








In 3 event provider implementations, flagd-java, go-feature-flag-web, and even my own implementation of flagd-js, authors have forgotten to properly implement
getState(which means the SDK assumes the provider is alreadyREADYand doesn't runinitialize().)This is an easy pitfall. To help with this, I'm making the implementation of
getStaterequired in the abstractEventProviderclass, and will do similarly in the JS-SDK. I think this is a reasonable proposal because theEventProviderclass is very new, and in the majority of cases a provider that can fire async events requires some kind of remote connection, so it will need initialization. This is technically a breaking change, but it would only impact the experimental events API, specifically theEventProviderimplementations which could only be a few days old at this point, and which (due to my previous point) likely should have implemented this anyway.It also adds some more doc about the importance of this method.
Relates to: open-feature/js-sdk#506