Skip to content

Conversation

thomaszurkan-optimizely
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely commented Mar 20, 2020

Summary

  1. remove all print statements.
  2. datastore memory backing store configurable.
  3. datastore memory backing changed from file to user defaults.
  4. default event handler uses memory with user defaults for tvOS and file based for iOS.
  5. max bytes for tvOS User Defaults datastore is 128k. 1M for iOS. Added unit tests.
  6. changed datafile handler to use data store file.
  7. fixed unit tests and tweaked data store file. Added removeItem to OPTDataStore.

@thomaszurkan-optimizely thomaszurkan-optimizely requested a review from a team as a code owner March 20, 2020 22:26
@thomaszurkan-optimizely thomaszurkan-optimizely changed the title chore (OPTDataStore): chore (OPTDataStore): Remove print statements and change memory store default backing store. Mar 20, 2020
@coveralls
Copy link

coveralls commented Mar 20, 2020

Coverage Status

Coverage decreased (-0.2%) to 98.555% when pulling 7d0eb50 on cleanUp into 7286fe6 on master.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Need small changes

Comment on lines 134 to 135


Copy link
Contributor

Choose a reason for hiding this comment

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

remove spaces

Comment on lines 123 to 125
set {

}
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Comment on lines 158 to 160
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Comment on lines 111 to 112
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove


XCTAssert(v2 == value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's clean up here test data which may be left from previous test:
UserDefaults.standard.removeObject(forKey: "testUserDefaultsTooBig")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is never saved because it is too big. :)

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

It looks good functionally. One concern is about if the datafile can fit in UserDefaults, and the overall space taken from UserDefaults together with event queues.

Comment on lines 296 to 304
public func removeItem(sdkKey:String) {
if let store = self as? DataStoreUserDefaults {
store.removeItem(sdkKey: sdkKey)
}
else if let store = self as? DataStoreFile<Data> {
store.removeItem(sdkKey: sdkKey)
}
else if let store = self as? DataStoreMemory<Data> {
store.removeItem(sdkKey: sdkKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

It must be for backward compatibility. Can't we leave it empty? All our datastores override it. Also we can move it to the end of OPTDataStore for readability.

public func removeItem(sdkKey: String) { }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no because that is the method called on the extension (i.e. the other implementation is not an override since it is an extension). the only alternative is to add it to the data store protocol directly.

}
else {
#if os(tvOS)
let store = DataStoreUserDefaults()
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks good, but I'm concerned about the datafile size which can grow big more than MB. They may not fit into UserDefaults max configs in many cases. Also with event queues, it can take substantial spaces in UserDefaults even if they can fit in 128KB each.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

even if you reach 512k in tvOS, the action is that the user is notified, it can actually grow beyond that. So, this is probably pretty safe. That said, if the datafile is too big, what choice do they have on tvOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

basically, the same thing will happen as happens now on tvOS. start async, caching fails, but you can continue. the bigger question may be do we want to disable polling for tvOS? i am really curious why the simulator doesn't fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Polling is optional, so we don't need to block it. They won't turn it on if not working.
We can also consider "Cache" folder as done in ObjC. Both methods are not fully reliable for keeping datafile cache and events.

jaeopt
jaeopt previously approved these changes Mar 25, 2020
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@jaeopt jaeopt self-requested a review March 26, 2020 22:05
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@jaeopt jaeopt merged commit 8b0f324 into master Mar 26, 2020
@jaeopt jaeopt deleted the cleanUp branch March 26, 2020 22:10
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