Skip to content

fix: sync init flow changed to support dynamic update #297

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

Merged
merged 5 commits into from
Mar 10, 2020

Conversation

jaeopt
Copy link
Contributor

@jaeopt jaeopt commented Feb 14, 2020

  • Add an option to dynamically update ProjectConfig on datafile cache update for sync init flow (this feature is disabled by default to be compatible with the old versions).
  • When periodic polling is enabled, the sync cache change always update ProjectConfig dynamically regardless of the setting above.

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

I left some comments. I'm out this week (maybe in Friday). But, I will check slack if you want to discuss anything or do updates to the PR. Thanks.

/// - doFetchDatafileBackground: This is for debugging purposes when
/// you don't want to download the datafile. In practice, you should allow the
/// background thread to update the cache copy (optional)
public func start(datafile: Data, doFetchDatafileBackground: Bool = true) throws {
public func start(datafile: Data,
doUpdateConfigOnNewDatafile: Bool = false,
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely Feb 18, 2020

Choose a reason for hiding this comment

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

These two parameters don't really make sense here. If you have doUpdateConfigOnNewDatafile as true but you have doFeatchDatafileBackground as false. It is an invalid combination. Maybe an enum might be better here with all valid combinations. Also, the default combination is probably not ideal if you have polling enabled which is not addressed in this combo or PR. So, you might want combos that include polling and what to do there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's not so clean as it should be. The reason I keep "doFetchDatafileBackground" is for API backward compatibility only, where we had this option for debugging support. We can let them override "doUpdateConfigOnNewDatafile" when they still want to disable fetch completely for debugging purpose.

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

Sorry for the confusion. I had one nit. To move the isPeriodicPolling enabled to a extension possibly next to the start extension. Thanks!

@@ -39,6 +40,14 @@ open class OptimizelyClient: NSObject {
}

let eventLock = DispatchQueue(label: "com.optimizely.client")

private var isPeriodicPollingEnabled: Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we make this an extension?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 98.713% when pulling 8500883 on jae/init-sync-flow into c70fc12 on master.

@jaeopt jaeopt merged commit b1c0282 into master Mar 10, 2020
@jaeopt jaeopt deleted the jae/init-sync-flow branch March 10, 2020 21:21
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.

3 participants