Skip to content

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Jul 24, 2024

  1. Allows for the common client to have customized data sources. This was used for testing here, but could be used for more specialized use-cases in the future.
  2. Adds the ability for start and identify to wait for values from LaunchDarkly instead of resolving with cached values when available.

With the previous wrapper SDK this behavior was controlled by the underlying SDK and those would operate similar to the new, optional, behavior.

For most uses cases it is both safer and higher performance to used cached values when they are available instead of only using those cached values as a fallback.

Ideally we would add new return values to start and identify. Next major version we should consider:
Cached, Timeout. While retaining the current value for completing via data from LD.

_dataSourceManager.identify(_context, completer);

if (loadedFromCache) {
if (loadedFromCache && !waitForNonCachedValues) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The actual change to identify and start logic.


typedef DataSourceFactoriesFn = Map<ConnectionMode, DataSourceFactory> Function(LDCommonConfig config, LDLogger logger, HttpProperties httpProperties);

Map<ConnectionMode, DataSourceFactory> _defaultFactories(LDCommonConfig config, LDLogger logger, HttpProperties httpProperties) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the default factories into a function. Now it will choose between provided and defaults.

/// option should NOT be used and instead flag changes should be listened to.
/// If [waitForNonCachedValues] is true, and an error is encountered, then
/// false may be returned even if cached values were loaded.
Future<bool> start({bool waitForNonCachedValues = false}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

So, if you want to use cached values on app start, but not on identify, then this supports that.

If you want to identify multiple contexts sequentially, and you want to ensure your cache gets updated, you can do that. You can also choose to use the cached values for the last context, being as that one would be updated in the background.

If you want to ensure you have "fresh" values when navigating to specific sections of your app, you could do that.

What this does not solve is the situation where someone wants to identify multiple contexts sequentially, wants the cache to be updated, but doesn't want the performance penalty. (One request was basically to allow the identify to continue and update the cache in the background, but concurrently start identifying a new context.)

Copy link
Member Author

Choose a reason for hiding this comment

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

If you want flag values to "not change", then you can evaluate all relevant flags after the identify and use those values.

Alternatively, you could set the SDK to offline after completing the identify, and then only go online again when you want to specifically update values.

@kinyoklion kinyoklion marked this pull request as ready for review July 24, 2024 18:44
@kinyoklion kinyoklion requested a review from a team as a code owner July 24, 2024 18:44
@kinyoklion kinyoklion merged commit 28f7efa into main Jul 31, 2024
@kinyoklion kinyoklion deleted the rlamb/sc-251068/identify-optionally-non-cached branch July 31, 2024 20:32
kinyoklion pushed a commit that referenced this pull request Aug 1, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.3.0](launchdarkly_common_client-v1.2.0...launchdarkly_common_client-v1.3.0)
(2024-07-31)


### Features

* Add support for waiting for non-cached values.
([#160](#160))
([28f7efa](28f7efa))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
kinyoklion pushed a commit that referenced this pull request Aug 1, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.7.0](4.6.0...4.7.0)
(2024-08-01)


### Features

* Add support for waiting for non-cached values.
([#160](#160))
([28f7efa](28f7efa))
* Update to common client 1.3.0
([#164](#164))
([3189d51](3189d51))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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