-
Notifications
You must be signed in to change notification settings - Fork 18
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
refactor: hide data source configuration behind dataSystem interface #189
Conversation
26d1cee
to
bd44019
Compare
@@ -9,13 +9,13 @@ import ( | |||
) | |||
|
|||
type dataStoreEvaluatorDataProviderImpl struct { |
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.
This change is because the existing read/write enabled DataStore
interface isn't actually needed in the evaluator. It only needs to be able to retrieve segments/flags.
@@ -24,21 +26,6 @@ type DataStore interface { | |||
// data, and then delete any previously stored items that were not in the input data. |
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.
These were moved into ReadOnlyStore
bd44019
to
de69ac4
Compare
de69ac4
to
d09e32d
Compare
@@ -583,13 +554,18 @@ func (client *LDClient) SecureModeHash(context ldcontext.Context) string { | |||
// this does not guarantee that the flags are up to date; if you need to know its status in more detail, use | |||
// [LDClient.GetDataSourceStatusProvider]. | |||
// |
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.
Added this comment because that's what our unit tests expect. Didn't see it documented.
// If this value is false, it means the client has not yet connected to LaunchDarkly, or has permanently | ||
// failed. See [MakeClient] for the reasons that this could happen. In this state, feature flag evaluations | ||
// will always return default values-- unless you are using a database integration and feature flags had | ||
// already been stored in the database by a successfully connected SDK in the past. You can use | ||
// [LDClient.GetDataSourceStatusProvider] to get information on errors, or to wait for a successful retry. | ||
func (client *LDClient) Initialized() bool { | ||
return client.dataSource.IsInitialized() | ||
if client.offline { |
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.
This logic used to work because if the client was in offline mode, then a NullDataSource
was instantiated (which returned true
for IsInitialized()).
Since dataSystem
doesn't expose IsInitialized
- just the DataAvailability
- we need to check that here explicitly. Simpler to understand.
This change defines a new
dataSystem
interface, used internally byLDClient
to implement all functionality related to data store and data source interactions.The purpose is to be able to swap out the implementation with one suited for FDv2 in a future PR.