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

refactor: hide data source configuration behind dataSystem interface #189

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented Sep 16, 2024

This change defines a new dataSystem interface, used internally by LDClient 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.

@cwaldren-ld cwaldren-ld force-pushed the cw/sdk-9-refactor-internal-data-interactions branch from 26d1cee to bd44019 Compare September 16, 2024 22:25
@@ -9,13 +9,13 @@ import (
)

type dataStoreEvaluatorDataProviderImpl struct {
Copy link
Contributor Author

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.
Copy link
Contributor Author

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

@cwaldren-ld cwaldren-ld force-pushed the cw/sdk-9-refactor-internal-data-interactions branch from bd44019 to de69ac4 Compare September 16, 2024 22:33
@cwaldren-ld cwaldren-ld force-pushed the cw/sdk-9-refactor-internal-data-interactions branch from de69ac4 to d09e32d Compare September 16, 2024 22:35
@@ -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].
//
Copy link
Contributor Author

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 {
Copy link
Contributor Author

@cwaldren-ld cwaldren-ld Sep 16, 2024

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.

@cwaldren-ld cwaldren-ld marked this pull request as ready for review September 16, 2024 22:43
@cwaldren-ld cwaldren-ld requested a review from a team as a code owner September 16, 2024 22:43
@cwaldren-ld cwaldren-ld merged commit de100b0 into v7 Sep 17, 2024
19 checks passed
@cwaldren-ld cwaldren-ld deleted the cw/sdk-9-refactor-internal-data-interactions branch September 17, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants