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
feat: isolate interfaces from SDK to improve testability #268
base: main
Are you sure you want to change the base?
feat: isolate interfaces from SDK to improve testability #268
Conversation
0e316a3
to
10e29be
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
+ Coverage 81.74% 81.92% +0.17%
==========================================
Files 10 10
Lines 964 979 +15
==========================================
+ Hits 788 802 +14
Misses 156 156
- Partials 20 21 +1 ☔ View full report in Codecov by Sentry. |
efeff46
to
57db4d6
Compare
57db4d6
to
24041fa
Compare
a6c2c55
to
1af6cf0
Compare
openfeature/openfeature_api.go
Outdated
// evaluationAPI wraps OpenFeature evaluation API functionalities | ||
type evaluationAPI struct { | ||
// ofApiImpl is an internal reference interface extending IOFApi | ||
type ofApiImpl interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on why this intermediate interface is necessary - can you clarify why it exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced this to support internal work and avoid direct access to singleton instance from other components like Client
. For example, a client instance needs to obtain the provider associate with its domain, so it rely on ForEvaluation
method exposed by this internal interface.
openfeature/event_executor.go
Outdated
// registerClientHandler registers a client level handler | ||
func (e *eventExecutor) registerClientHandler(clientName string, t EventType, c EventCallback) { | ||
// RegisterClientHandler registers a client level handler | ||
func (e *EventExecutor) RegisterClientHandler(clientName string, t EventType, c EventCallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe name this AddClientHandler
to reflect the relationship to AddHandler
(i.e. the same except scoped), or perhaps rename AddHandler
above as RegisterHandler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will rename to AddClientHandler
. Regarding AddHandler
, this is already public so I will avoid a breaking change and keep it there.
76d0a50
to
275a505
Compare
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
64f0598
to
30e3e4e
Compare
This PR
Partially address #266 by providing interface contracts for the SDK. There are no breaking changes in this change
I have introduced
IEvaluation
interface, which represents the general OpenFeatuer API layer [1]. Before this change, there was no such interface so mocking API interactions was impossible. To obtain the singleton instance ofIEvaluation
interface, I have introducedGetApiInstance()
helper.Consider the example below,
In the future, we can update our documentation to make API instance based operations the preferred interaction method.
Further,
IEvaluation
exposes client creation methodsGetClient()
&GetNamedClient(clientName string)
(similar to spec [2]). These methods returnIClient
instances, making it easy to test OpenFeature client related operations.[1] - https://openfeature.dev/specification/sections/flag-evaluation
[2] - https://openfeature.dev/specification/sections/flag-evaluation#creating-clients