-
Notifications
You must be signed in to change notification settings - Fork 930
[Multi-Tab] Master Election #501
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
schmidt-sebastian
merged 19 commits into
firestore-multi-tab
from
multitab-masterelection
Mar 1, 2018
Merged
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a492edb
Adding Master Election
schmidt-sebastian 0d14759
Updating TODO message in LocalStore.
schmidt-sebastian 366f830
Making Spec Tests consistent.
schmidt-sebastian 75b08c8
[AUTOMATED]: Prettier Code Styling
schmidt-sebastian 64b0eb5
Setting visibilityState on client init
schmidt-sebastian 5113ec3
Merge
schmidt-sebastian 38d23db
Addressing feedback
schmidt-sebastian 1f78076
[AUTOMATED]: Prettier Code Styling
schmidt-sebastian 3116e70
Cleanup
schmidt-sebastian ea07c8e
Addressing review feedback.
schmidt-sebastian 010729b
Removing the persistence Spec test
schmidt-sebastian 806a86a
Cleanup for canActAsPrimary
schmidt-sebastian 2e10f8a
Comment Cleanup
schmidt-sebastian 8481ee5
Adding TODO to remove tryAcquirePrimaryLease
schmidt-sebastian 972cb4c
Addressing comments
schmidt-sebastian 9111376
Adding assert to AsyncQueue
schmidt-sebastian 042a8e5
[AUTOMATED]: Prettier Code Styling
schmidt-sebastian 50a6051
Last round of feedback
schmidt-sebastian 35dfb02
[AUTOMATED]: Prettier Code Styling
schmidt-sebastian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,13 +121,19 @@ export class SyncEngine implements RemoteSyncer { | |
[uidKey: string]: SortedMap<BatchId, Deferred<void>>; | ||
}; | ||
private targetIdGenerator = TargetIdGenerator.forSyncEngine(); | ||
private isPrimary = false; | ||
|
||
constructor( | ||
private localStore: LocalStore, | ||
private remoteStore: RemoteStore, | ||
private currentUser: User | ||
) {} | ||
|
||
// Only used for testing. | ||
get isPrimaryClient() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this is only used for testing, and I suspect this should remain the case. Add a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I suspect you are right. Comment added. |
||
return this.isPrimary; | ||
} | ||
|
||
/** Subscribes view and error handler. Can be called only once. */ | ||
subscribe(viewHandler: ViewHandler, errorHandler: ErrorHandler): void { | ||
assert( | ||
|
@@ -616,4 +622,9 @@ export class SyncEngine implements RemoteSyncer { | |
return this.remoteStore.handleUserChange(user); | ||
}); | ||
} | ||
|
||
applyPrimaryState(isPrimary: boolean): Promise<void> { | ||
this.isPrimary = isPrimary; | ||
return Promise.resolve(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's a non-obvious ordering dependency here, I think this warrants a comment:
// NOTE: This will immediately call the listener, so we make sure to set it after localStore / remoteStore are started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doone.