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

Palpatim/crash resuming from background #171

Merged
merged 12 commits into from
Feb 6, 2019

Conversation

palpatim
Copy link
Contributor

@palpatim palpatim commented Feb 5, 2019

Issue #, if available:
#160

Description of changes:

  • Splits databases into separate files to reduce contention. Provides migration utility from old-style to new-style cache.
  • Wires Promises into MutationQueue flow to make async model easier to follow. Lays groundwork for future Promises integration.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

larryonoff and others added 9 commits January 31, 2019 12:41
* master:
  Remove unused contentMap field from persistent queue. Fixes #33. (#169)
…configs

- Renamed `AWSSQLLiteNormalizedCacheError` to `AWSAppSyncQueriesCacheError`
- Deprecated `AWSSQLLiteNormalizedCache`
- Deprecated `databaseURL` option to `AWSAppSyncClientConfiguration`
- Deprecated `MutationCache` protocol
@palpatim palpatim added AppSync contribution Community contribution PRs labels Feb 5, 2019
@palpatim palpatim self-assigned this Feb 5, 2019
@palpatim palpatim requested a review from rohandubal February 5, 2019 01:22
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the license is ASL 1.0 and not apache. I may have missed this previously(If this isn't the first time adding this header)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out, will fix

private let data = Expression<Data>("data")
private let recordState = Expression<String>("recordState")
private let timestamp = Expression<Date>("timestamp")
private let s3Bucket = Expression<String?>("s3Bucket")
Copy link
Contributor

Choose a reason for hiding this comment

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

With some customer asks about supporting more than 1 s3 file/ complex object per mutation, do you think it is a good idea to use this opportunity to change the schema to hold an array of s3 objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to put that in a separate change, since this PR is a) targeted toward refactoring database handling; and b) quite large enough. :)

import Foundation
import SQLite

final class SQLiteSerialization {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

import Foundation

/// Errors thrown from the Queries Cache
public enum AWSAppSyncQueriesCacheError: Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way in which AWSAppSyncQueriesCacheError can inherit from AWSSQLLiteNormalizedCacheError so that the customer experience can be slightly better? We can still deprecate AWSSQLLiteNormalizedCacheError and get rid of it eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered some options but couldn't find a way to make this a non-breaking change. Value types like Enums can't inherit in Swift, and any change to the throwing type is going to potentially impact customers who are catching that specifically.

The three options I considered:

  1. Leave it as-is
  2. Remove AWSSQLLiteNormalizedCacheError in favor of the new error type
  3. Deprecate AWSSQLLiteNormalizedCacheError in favor of the new error type

I don't favor Option 1. AWSSQLLiteNormalizedCacheError as a type name has some semantic confusion (What's a normalized cache? Why is SQLLite specified? Why is SQLite misspelled? :) )

I went back & forth between Option 2 & Option 3 and only settled on deprecation because that's our traditional way of doing things. I could be convinced to do Option 2--just removing it altogether. Deprecating means that customers who are actually taking meaningful action based on the error type will see a warning, but won't be forced to deal with the potential change in behavior. However, for customers who aren't doing anything critical (e.g. they're adding or suppressing logging based on the error type), it's an unexpected change to remove it.

A deprecation with a FixIt seemed the best compromise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for the detailed explanation!

/// - offlineMutations: The file path to create or connect to the cache for the offline mutation queue.
/// - queries: The file path to create or connect to the cache for the local query cache.
/// - subscriptionMetadataCache: The file path to create or connect to the cache for subscription metadata.
init(offlineMutations: URL?, queries: URL?, subscriptionMetadataCache: URL?) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be marked public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch, thanks.

@palpatim palpatim merged commit 64bd6f2 into master Feb 6, 2019
@palpatim palpatim deleted the palpatim/crash-resuming-from-background branch February 6, 2019 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Community contribution PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants