Skip to content

Mark outgoing mutation as inProcess if nextEventPromise exists #392

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 1 commit into from
Apr 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ extension AWSMutationDatabaseAdapter: MutationEventIngester {
completionPromise: @escaping Future<MutationEvent, DataStoreError>.Promise) {

log.verbose("\(#function) mutationEvent: \(mutationEvent)")
storageAdapter.save(mutationEvent, condition: nil) { result in
var eventToPersist = mutationEvent
if nextEventPromise != nil {
eventToPersist.inProcess = true
Copy link
Contributor

Choose a reason for hiding this comment

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

just to clarify if I understand it correctly. This is important in case the mutation event fails so it can be retried later on, is that a correct statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, that is not a correct statement.

To give you a little bit more context, this code should actually be refactored, and technically doesn't belong here. nextEventPromise is assigned if the outgoingMutationQueue asks the AWSMutationDatabaseAdapter for a mutationEvent to be sent out, but the AWSMutationDatabaseAdapter doesn't have an event to offer up. So, when this happens, the AWSMutationDatabaseAdapter saves this promise, and offers up an event when a mutationEvent is ready to be sent out (e.g. customer makes a mutation).

We can sync offline on this, and I can show you a component diagram of various pieces at work here.

}
storageAdapter.save(eventToPersist, condition: nil) { result in
switch result {
case .failure(let dataStoreError):
self.log.verbose("\(#function): Error saving mutation event: \(dataStoreError)")
Expand Down