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
Initial implementation of the Sync Manager #1447
Conversation
* Base class for sync manager errors. Generally should not | ||
* have concrete instances. | ||
*/ | ||
open class SyncManagerException(msg: String) : Exception(msg) |
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.
Maybe sealed classes could be an alternative here.
9715fe7
to
084d4c9
Compare
78f318b
to
b6fd39d
Compare
2 things not fully finished
First of these I'll finish tomorrow ASAP (had more time in meetings than anticipated today) which should unblock @grigoryk's ability to test against this branch. 2nd I'll finish before landing but it shouldn't impact the overall shape of things. As-is this probably should unblock @linacambridge's ability to integrate clients engine. |
95b9581
to
9f84c35
Compare
Ignore the dep summary failure, that's because this currently forces lockwise to contain the places deps, which i'll fix after I do a little testing to make sure this all works as intended. |
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.
This is looking good. However, I'd like to better understand why "accepted" isn't supported? I'd really like to avoid having Fenix spend effort on something we want to go away in the short term (and I really don't want "accepted" to not happen short term). It's particularly important IMO because IIUC we will be implementing "choose what to sync" sooner rather than later for Fenix, and because the set of engines supported is different to desktop we'll have a problem. IOW, we need to implement support for "accepted" on desktop ASAP rather than deferring the implementation on Fenix!)
(I'm fine with the spelling of "accepted" in the RFC not being exactly how it is implemented - if you think that's necessary, let's discuss it!)
components/sync15/src/state.rs
Outdated
@@ -87,6 +84,34 @@ pub struct GlobalState { | |||
pub keys: EncryptedBso, | |||
} | |||
|
|||
fn same_declined(a: &[String], b: &[String]) -> bool { |
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.
While this looks correct, does a unit test for it make sense?
components/sync15/src/state.rs
Outdated
|
||
impl MetaGlobalRecord { | ||
// TODO: this function needs to change once we understand 'accepted'. | ||
pub fn update_declined_engines(&mut self, changes: &HashMap<String, bool>) -> bool { |
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.
Is this better named "maybe_update_declined"? Either way, a comment explaining the bool return probably makes sense.
@@ -66,6 +66,9 @@ pub struct SyncResult { | |||
/// The general health. |
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.
does the comment at the top of this struct need updating?
crate, and in some cases stretches (or arguably breaks) the abstraction barrier | ||
that `sync15` puts up. | ||
|
||
Unfortunately, places/logins/etc depend on sync15 directly, and so to prevent a |
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.
It seems like some of the issue here WRT stretching/breaking the abstractions is keeping sync_multiple in sync15, but logins (and even places) probably doesn't actually need that?
pub struct SyncManager { | ||
mem_cached_state: Option<MemoryCachedState>, | ||
places: Weak<PlacesApi>, | ||
logins: Weak<Mutex<PasswordEngine>>, |
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.
The fact logins has a Mutex but PlacesApi doesn't seems like there's some inconsistency here that should be abstracted away lower?
(The fact we can't just work with traits surprises me too, but I guess there's a good reason hidden away somewhere)
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.
This is looking great, and I ❤️ the sync_multiple
refactor, that function was getting really long and complicated. I also wouldn't mind seeing this again with accepted
, but I left a few comments and questions in the meantime!
components/sync_manager/android/src/main/java/mozilla/appservices/syncmanager/Errors.kt
Outdated
Show resolved
Hide resolved
components/sync_manager/android/src/main/java/mozilla/appservices/syncmanager/Errors.kt
Outdated
Show resolved
Hide resolved
components/sync_manager/android/src/main/java/mozilla/appservices/syncmanager/RustError.kt
Outdated
Show resolved
Hide resolved
components/sync_manager/android/src/main/java/mozilla/appservices/syncmanager/SyncManager.kt
Outdated
Show resolved
Hide resolved
…ed before this is actually ready for review
…of engines into the next states
@linacambridge This should be ready for you to take another look I think? |
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.
Looks great!
components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt
Show resolved
Hide resolved
Will land once green |
Fixes #1382, although this might just become a rolling PR, since I don't think we want to land broken bindings.
See also mozilla-mobile/android-components#2727
This also required some number of changes to various other pieces in support.
The biggest differences between this and the API @mhammond proposed in our docs:
SyncReason.ENABLED_CHANGED
for cases where we're triggering a sync of no engines just to update enabled.Compared to #1208 (which is... surprisingly still not landed...), I still only return the
declined
list over the FFI. It's not 100% clear that I should expose anything more than that?This is a draft PR, but I'd like feedback on the (Kotlin parts of the) API so far. Note that I'll be deprecating (eventually removing the existing kotlin sync APIs), but that's not yet reflected here.
r? @Amejia481, @grigoryk, @mhammond
Pull Request checklist
cargo test --all
produces no test failurescargo clippy --all --all-targets --all-features
runs without emitting any warningscargo fmt
does not produce any changes to the code./gradlew ktlint detekt
runs without emitting any warningsswiftformat --swiftversion 4 megazords components/*/ios && swiftlint
runs without emitting any warnings or producing changes[ci full]
to the PR title.