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

Added retry/restart logic to RemoteSyncEngine without cancel downstream components #322

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

wooj2
Copy link
Contributor

@wooj2 wooj2 commented Feb 16, 2020

This handles logic to restart the remote sync engine, without actually canceling downstream components.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@wooj2 wooj2 requested a review from palpatim February 16, 2020 22:42
@wooj2 wooj2 added datastore Issues related to the DataStore category P0 labels Feb 17, 2020
@@ -17,6 +17,7 @@ enum RemoteSyncEngineEvent {
case subscriptionsActivated
case mutationQueueStarted
case syncStarted
case cleanedUp
Copy link
Member

Choose a reason for hiding this comment

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

BTW, while I'm thinking about it, I like the idea you're promoting (intentionally or not) of normalizing our naming: State can represent a point-in-time view of a system, and could be thought of as something managed internally. Event can represent an external report of a state transition, even if it doesn't literally represent a change from one State to another.

@wooj2 wooj2 requested a review from drochetti February 18, 2020 17:53
Copy link
Contributor

@drochetti drochetti left a comment

Choose a reason for hiding this comment

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

a couple of minor comments, nothing that blocks the this PR.

Comment on lines +47 to +48
self.mutationRetryNotifier = nil
self.stateMachine.notify(action: .receivedStart)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indentation?

I just realized our indentation rule is not enforced by SwiftFormat... it's currently disabled. I wonder why...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm indentation seems fine to me? i'm selecting everything and hitting "Ctrl + i", and there doesn't seem to be any updates to the formatting of the code...

do {
networkReachabilityPublisher = try reachability.reachabilityPublisher()
} catch {
log.error("\(#function): Unable to listen on reachability: \(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 this unexpected? In case it fails what is the side-effect? I'm guessing in case it disconnects it won't attempt to reconnect, is that the case?

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 believe this code is correct. If the networkReachabilityPublisher does not initialized due to some exception being thrown, then our retry logic will be based purely on the exponential backoff (versus exponential backoff w/ using the status of reachability).

I looked into the reachability code, and it seems that it is possible for reachability to fail during initialization, so, we kept the interface to return an optional instance.

@wooj2 wooj2 changed the base branch from master-RSEState to master February 20, 2020 00:51
@wooj2 wooj2 changed the base branch from master to master-RSEState February 20, 2020 00:52
@wooj2 wooj2 changed the base branch from master-RSEState to master February 20, 2020 00:53
@wooj2 wooj2 force-pushed the master-RSEState-Restart branch from 2a49d3a to 782de9c Compare February 20, 2020 00:54
@wooj2 wooj2 merged commit d61b5cc into master Feb 20, 2020
@wooj2 wooj2 deleted the master-RSEState-Restart branch February 20, 2020 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants